private void btnProcesar_Click(object sender, EventArgs e)
        {
            this.StsProgressBar1.Value = 20;
            this.StsLabel1.Text        = "Llenando Tabla Principal";
            this.StsProgressBar1.Value = 20;
            try
            {
                this.StsProgressBar1.Value = 33;
                this.StsLabel1.Text        = "Llenando Tabla Principal";
                this.StsProgressBar1.Value = 33;

                #region Llenando el dataGridView Principal
                if (this.TxbPath.Text.Length != 0)
                {
                    DataSet DS;
                    DS = LeerExcel.TenorZandor(this.TxbPath.Text);
                    dataGridView1.DataSource = DS.Tables[0];
                    dataGridView1.AutoResizeColumns();

                    foreach (DataGridViewRow row in dataGridView1.Rows)
                    {
                        row.Cells[0].Value = true;
                    }
                    this.chbMarcar.Checked = true;

                    int I = 0;
                    foreach (DataGridViewColumn Column in dataGridView1.Columns)
                    {
                        if (I > 0)
                        {
                            Column.ReadOnly = true;
                        }
                        I += 1;
                    }
                }
                else
                {
                    MessageBox.Show("Seleccione un archivo");
                }
                #endregion

                this.StsProgressBar1.Value = 69;
                this.StsLabel1.Text        = "Llenando Tabla Con Registros que se actualizaran";
                this.StsProgressBar1.Value = 69;



                #region LLenado el DataGridView con los registros relacionados

                #region LLenado de DataTable que se enviara en el SP

                DataTable dt = new DataTable();
                dt.Columns.Add("Incluir");
                dt.Columns.Add("Id");
                dt.Columns.Add("Sello");
                dt.Columns.Add("Tenor");
                dt.Columns.Add("Humedad");

                DataRow Row = dt.NewRow();

                foreach (DataGridViewRow row in dataGridView1.Rows)
                {
                    bool   incluir = Convert.ToBoolean(row.Cells[0].Value);
                    int    id      = Convert.ToInt32(row.Cells[1].Value);
                    string sello   = Convert.ToString(row.Cells[2].Value);
                    double tenor   = Convert.ToDouble(row.Cells[3].Value);
                    double humedad = Convert.ToDouble(row.Cells[4].Value);


                    Row["incluir"] = incluir;
                    Row["Id"]      = id;
                    Row["Sello"]   = sello;
                    Row["Tenor"]   = tenor;
                    Row["Humedad"] = humedad;
                    dt.Rows.Add(Row);
                    Row = dt.NewRow();
                }
                #endregion

                SqlParameter[] Parametros_Consulta1 = new SqlParameter[3];
                Parametros_Consulta1[0] = new SqlParameter("@Op", "S");
                Parametros_Consulta1[1] = new SqlParameter("@Consecutivo", "0");
                Parametros_Consulta1[2] = new SqlParameter("@TablaExcelPM", dt);

                DataSet DataS;
                DataS = LlenarGrid.Datos("Sp_ConsultaDatosPM", Parametros_Consulta1);

                dataGridView2.DataSource = DataS.Tables[0];
                dataGridView2.AutoResizeColumns();

                this.StsProgressBar1.Value = 90;
                this.StsLabel1.Text        = "Llenando Tabla Con Registros que NO se actualizaran";
                this.StsProgressBar1.Value = 90;

                SqlParameter[] Parametros_Consulta2 = new SqlParameter[3];
                Parametros_Consulta2[0] = new SqlParameter("@Op", "N");
                Parametros_Consulta2[1] = new SqlParameter("@Consecutivo", "0");
                Parametros_Consulta2[2] = new SqlParameter("@TablaExcelPM", dt);

                DataSet DataN;
                DataN = LlenarGrid.Datos("Sp_ConsultaDatosPM", Parametros_Consulta2);

                dataGridView3.DataSource = DataN.Tables[0];
                dataGridView3.AutoResizeColumns();
            }
            catch (Exception Exc)
            {
                MessageBox.Show("OCURRIÓ UN ERROR AL CONSULTAR O CARGAR LOS DATOS..: \n\n" + Exc.Message, "Error del Sistema", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            #endregion


            this.StsProgressBar1.Value = 75;
            this.StsProgressBar1.Value = 100;
            this.StsLabel1.Text        = "Listo";
            this.StsProgressBar1.Value = 0;
        }
        private void btnProcesar_Click(object sender, EventArgs e)
        {
            this.StsLabel1.Text        = "Llenando Encabezado";
            this.StsProgressBar1.Value = 25;
            #region Llenando el Encabezado
            if (this.TxbPath.Text.Length != 0)
            {
                Ent_EncabezadoExcel Encabezado = LeerExcel.Encabezado(this.TxbPath.Text);
                this.TxbCliente.Text    = Encabezado.Cliente;
                this.TxbOrden.Text      = Encabezado.Orden;
                this.TxbLugar.Text      = Encabezado.Lugar;
                this.TxbMuestras.Text   = Encabezado.Muestras;
                this.TxbReferencia.Text = Encabezado.Referencia;
                this.TxbReporte.Text    = Encabezado.Reporte;
                this.TxbRecepcion.Text  = Encabezado.Recepcion;
            }
            #endregion


            this.StsLabel1.Text        = "Llenando Tabla Principal";
            this.StsProgressBar1.Value = 50;
            #region Llenando el dataGridView Principal
            if (this.TxbPath.Text.Length != 0)
            {
                DataSet DS;
                DS = LeerExcel.DatosGQ15(this.TxbPath.Text);
                dataGridView1.DataSource = DS.Tables[0];
                dataGridView1.AutoResizeColumns();

                foreach (DataGridViewRow row in dataGridView1.Rows)
                {
                    row.Cells[0].Value = true;
                }
                this.chbMarcar.Checked = true;

                int I = 0;
                foreach (DataGridViewColumn Column in dataGridView1.Columns)
                {
                    if (I == 0)
                    {
                        Column.ReadOnly = false;
                    }
                    else
                    {
                        Column.ReadOnly = true;
                    }
                    I += 1;
                }
            }
            else
            {
                MessageBox.Show("Seleccione un archivo");
            }
            #endregion


            this.StsLabel1.Text        = "Llenando Tabla Resumen";
            this.StsProgressBar1.Value = 75;
            #region LLenado de DataGrid Auxiliar
            DataTable dt = new DataTable();
            dt.Columns.Add("Id");
            dt.Columns.Add("IdPadre");
            dt.Columns.Add("Sello");
            dt.Columns.Add("Tenor");
            DataRow Row     = dt.NewRow();
            string  IdLim   = "";
            string  LimSupP = "";
            string  G_TM    = "";
            int     Id      = 1;

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                string SelloP = Convert.ToString(row.Cells[2].Value);
                if (SelloP.IndexOf("a") + SelloP.IndexOf("b") + SelloP.IndexOf("c") == -3)
                {
                    IdLim   = Convert.ToString(row.Cells[1].Value);
                    LimSupP = Convert.ToString(row.Cells[2].Value);
                    G_TM    = Convert.ToString(row.Cells[5].Value);

                    Row["Id"]      = Id;
                    Row["IdPadre"] = IdLim;
                    Row["Sello"]   = LimSupP;
                    Row["Tenor"]   = G_TM;
                    dt.Rows.Add(Row);
                    Row = dt.NewRow();
                    Id++;
                }
            }

            DataSet DataS = new DataSet();
            DataS.Tables.Add(dt);
            dataGridView2.DataSource = DataS.Tables[0];
            dataGridView2.AutoResizeColumns();

            try
            {
                foreach (DataGridViewRow Row2 in dataGridView2.Rows)
                {
                    string         SelloConsulta = Convert.ToString(Row2.Cells[2].Value);
                    SqlParameter[] Parametros    = new SqlParameter[1];
                    Parametros[0] = new SqlParameter("@Sello", SelloConsulta);

                    ConsultaEntidades Entidad = new ConsultaEntidades();
                    Ent_MinaSello     Reader  = new Ent_MinaSello();
                    Reader = Entidad.MinaSello("ConsultarSelloSGS", Parametros);

                    if (Reader.Consecutivo == 0)
                    {
                        dataGridView2.Rows[Row2.Index].DefaultCellStyle.BackColor = Color.SkyBlue;
                    }
                }
            }
            catch (Exception Ext)
            {
                MessageBox.Show(Ext.Message);
            }


            #endregion


            for (int i = 0; i < 1000; i++)
            {
                i += 1;
            }
            this.StsProgressBar1.Value = 100;
            this.StsLabel1.Text        = "Listo";
            this.StsProgressBar1.Value = 0;
        }
        private void btnProcesar_Click(object sender, EventArgs e)
        {
            this.StsLabel1.Text        = "Llenando Encabezado";
            this.StsProgressBar1.Value = 50;
            #region Llenando el Encabezado
            if (this.TxbPath.Text.Length != 0)
            {
                Ent_EncabezadoHume Encabezado = LeerExcel.EncabezadoHume(this.TxbPath.Text);
                this.TxbFecha.Text                  = Encabezado.Fecha;
                this.TxbMuestras.Text               = Encabezado.Muestras;
                this.TxbCliente.Text                = Encabezado.Cliente;
                this.TxbAuUnidad.Text               = Encabezado.AuUnidad;
                this.TxbAuMetodo.Text               = Encabezado.AuMetodo;
                this.TxbAgUnidad.Text               = Encabezado.AgUnidad;
                this.TxbAgMetodo.Text               = Encabezado.AgMetodo;
                this.TxbHumeUnidad.Text             = Encabezado.HumedadUnd;
                this.TxbHumeMetodo.Text             = Encabezado.HumedadMet;
                this.TxbTipoMuestra.Text            = Encabezado.TipoMuestras;
                this.TxbOrden.Text                  = Encabezado.Orden;
                this.TxbClienteOrden.Text           = Encabezado.ClienteOrden;
                this.TxbNumMuestras.Text            = Encabezado.NumMuestras;
                this.TxbFechaMuestreo.Text          = Encabezado.FechaMuestreo;
                this.TxbFechaReporte.Text           = Encabezado.FechaReporte;
                this.TxbNotas.Text                  = Encabezado.Notas;
                this.TxbCodigoPreparacion.Text      = Encabezado.CodigoPrepa;
                this.TxbDescripcionPreparacion.Text = Encabezado.DescripcionPrepa;
                this.TxbCodigoAnalisis.Text         = Encabezado.CodigoAnalisis;
                this.TxbDescripcionAnalisis.Text    = Encabezado.DescripcionAnalisis;
                this.LblZC.Text = Encabezado.Orden;
            }
            #endregion



            this.StsLabel1.Text        = "Llenando Tabla Principal";
            this.StsProgressBar1.Value = 75;
            #region Llenando el dataGridView Principal
            if (this.TxbPath.Text.Length != 0)
            {
                DataSet DS;
                DS = LeerExcel.DatoHumedad(this.TxbPath.Text);
                dataGridView1.DataSource = DS.Tables[0];
                dataGridView1.AutoResizeColumns();
            }
            else
            {
                MessageBox.Show("Seleccione un archivo");
            }
            #endregion

            this.StsLabel1.Text        = "Marcando Sellos no reportados";
            this.StsProgressBar1.Value = 90;

            #region Marcando Sellos no reportados
            try
            {
                foreach (DataGridViewRow Row2 in dataGridView1.Rows)
                {
                    string         SelloConsulta = Convert.ToString(Row2.Cells[1].Value);
                    SqlParameter[] Parametros    = new SqlParameter[1];
                    Parametros[0] = new SqlParameter("@Sello", SelloConsulta);

                    ConsultaEntidades Entidad = new ConsultaEntidades();
                    Ent_MinaSello     Reader  = new Ent_MinaSello();
                    Reader = Entidad.MinaSello("ConsultarSelloSGS", Parametros);

                    if (Reader.Consecutivo == 0)
                    {
                        dataGridView1.Rows[Row2.Index].DefaultCellStyle.BackColor = Color.SkyBlue;
                    }
                }
            }
            catch (Exception Ext)
            {
                MessageBox.Show(Ext.Message);
            }
            #endregion

            for (int i = 0; i < 10000; i++)
            {
            }

            this.StsLabel1.Text        = "Listo";
            this.StsProgressBar1.Value = 100;
            this.StsProgressBar1.Value = 0;
        }