Exemple #1
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 != "")
            {
                datos = FuncionesExcel.GetData(pathFile);
                dataRows.AutoGenerateColumns = true;
                dataRows.DataSource          = datos;
                dataRows.ClearSelection();
                lblRows.Text = "N° Filas : " + dataRows.RowCount.ToString();
            }
        }
        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);
                }
            }
        }