private void dgDetalle_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                DataGridViewRow dRow = dgDetalle.Rows[e.RowIndex];
                _drow = dRow.Index.ToString();

                ETejeduriaDet objTJ = new ETejeduriaDet();

                objTJ.Id_producto = txt_idTejido.Text;
                objTJ.Nu_correficha = txt_nuFicha.Text;

                objTJ.Nu_secuen = (dRow.Cells["_nu_secuen"].Value == null) ? "" : dRow.Cells["_nu_secuen"].Value.ToString();
                objTJ.Id_numalim = (dRow.Cells["Alim"].Value == null) ? "" : dRow.Cells["Alim"].Value.ToString();
                objTJ.Ds_distrib = (dRow.Cells["Distribucion"].Value == null) ? "" : dRow.Cells["Distribucion"].Value.ToString();
                objTJ.Ds_estruct = (dRow.Cells["estructura"].Value == null) ? "" : dRow.Cells["estructura"].Value.ToString();
                objTJ.Id_prodhilo = (dRow.Cells["idHilo"].Value == null) ? "" : dRow.Cells["idHilo"].Value.ToString();

                objTJ.ds_prodhilo = (dRow.Cells["Hilo"].Value == null) ? "" : dRow.Cells["Hilo"].Value.ToString();
                objTJ.Ds_tipfibra = (dRow.Cells["tipo_fibra"].Value == null) ?  "" : dRow.Cells["tipo_fibra"].Value.ToString();
                objTJ.Ds_carachilo = (dRow.Cells["carac_hilo"].Value == null) ? "" : dRow.Cells["carac_hilo"].Value.ToString();
                objTJ.Ds_titulo = (dRow.Cells["titulo"].Value == null) ? "" : dRow.Cells["titulo"].Value.ToString();
                objTJ.Id_vlustre = (dRow.Cells["idLustre"].Value == null) ?  "" : dRow.Cells["idLustre"].Value.ToString();
                objTJ.ds_lustre = (dRow.Cells["lustre"].Value == null) ? "" : dRow.Cells["lustre"].Value.ToString();
                objTJ.Nu_torsion = (dRow.Cells["Nu_torsion"].Value == null) ? "" : dRow.Cells["Nu_torsion"].Value.ToString();
                objTJ.Id_clipro = (dRow.Cells["idProv"].Value == null) ? "" : dRow.Cells["idProv"].Value.ToString();
                objTJ.ds_razsoc = (dRow.Cells["proveedor"].Value == null) ? "" : dRow.Cells["proveedor"].Value.ToString();
                objTJ.Nu_lote = (dRow.Cells["Lote"].Value == null) ? "" : dRow.Cells["Lote"].Value.ToString();
                objTJ.Ds_etiqueta = (dRow.Cells["etiqueta"].Value == null) ? "" : dRow.Cells["etiqueta"].Value.ToString();
                objTJ.Nu_porhilo = (dRow.Cells["porHiloCrudo"].Value == null) ? 0 : Convert.ToDecimal(dRow.Cells["porHiloCrudo"].Value.ToString());
                objTJ.Nu_porhiloaca = (dRow.Cells["porHiloAcab"].Value == null) ? 0 : Convert.ToDecimal(dRow.Cells["porHiloAcab"].Value.ToString());

                objTJ.Nu_tension = (dRow.Cells["nu_tension"].Value == null) ? 0 : Convert.ToDecimal(dRow.Cells["nu_tension"].Value.ToString());
                objTJ.Nu_bobinas = (dRow.Cells["nu_bobinas"].Value == null) ? 0  : Convert.ToInt16(dRow.Cells["nu_bobinas"].Value.ToString());
                objTJ.Nu_alimenta = (dRow.Cells["nu_aliment"].Value == null) ? 0  : Convert.ToInt16(dRow.Cells["nu_aliment"].Value.ToString());
                objTJ.Mt_preuni = (dRow.Cells["pre_uni"].Value == null) ? 0 : Convert.ToDecimal(dRow.Cells["pre_uni"].Value.ToString());

                objTJ.Mt_subtotcon = (dRow.Cells["Sub_total"].Value == null) ? 0 : Convert.ToDecimal(dRow.Cells["Sub_total"].Value.ToString());

                ///
                frmModalDetalle frmpop = new frmModalDetalle();
                frmpop.FormParent = this;
                frmpop.EstadoDet = 2;

                frmpop.LLenarCampos(objTJ);

                /// DETALLE DE LONGITUD MALLA

                ETejeduria_DetMall objLM = new ETejeduria_DetMall();
                //DataGridViewRow dRow2 = dgTJLM.Rows[e.RowIndex];

                for (int i = 0; dgTJLM.Rows.Count > i; i++)
                {
                    var nu_secuen = dgTJLM.Rows[i].Cells["nu_secuen"].Value;
                    var nu_item = dgTJLM.Rows[i].Cells["nu_item"].Value;
                    var nu_longmalla = dgTJLM.Rows[i].Cells["nu_longmalla"].Value;
                    var st_anulado = dgTJLM.Rows[i].Cells["_st_anulado"].Value;
                    if (nu_secuen.ToString() == objTJ.Nu_secuen.ToString() & st_anulado.ToString()=="0")
                    {
                        objLM.Nu_secuen = nu_secuen.ToString();
                        objLM.Nu_item = nu_item.ToString();
                        objLM.Nu_longmalla = Convert.ToDecimal(nu_longmalla);
                        objLM.St_anulado = st_anulado.ToString();
                        frmpop.LlenarGrillaLM2(objLM, this);
                    }
                }

                frmpop.ShowDialog();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void FrmTejeduria_mnt_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.N && e.Control)
            {
                Nuevo();
            }

            else if (e.KeyCode == Keys.I && e.Control)
            {
                try
                {

                    frmModalDetalle frmps = new frmModalDetalle();
                    frmps.FormParent = this;
                    frmps.EstadoDet = 1;
                    frmps.ShowDialog();

                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }

            }

            else if (e.KeyCode == Keys.R && e.Control)
            {
                NuevoItem();

            }
            else if (e.KeyCode == Keys.B && e.Control)
            {
                FrnTejeduria_qry frmoc = new FrnTejeduria_qry();
                frmoc.pasard += new FrnTejeduria_qry.pasar(EjecutarTejeduria);
                frmoc.ShowDialog();

            }

            else if (e.KeyCode == Keys.G && e.Control)
            {
                var idCli = txt_IdCli.Text;
                var idTejido = txt_idTejido.Text;
                var idMercado = cb_Mercado.Text;
                var idDestino = cb_Destino.Text;
                var idAncho = txt_InfTecCrudo_idancho.Text;
                var idColor = txtIdColor.Text;

                if ((idCli != "") & (idTejido != "") & (idMercado != "") & (idDestino != "") & (idAncho != "") & (idColor != ""))
                {
                    Grabar();
                }
                else
                {
                    MessageBox.Show("Falta ingresar un dato", "Verificar", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

            }

            else if (e.KeyCode == Keys.E && e.Control)
            {
                HabilitarTexto(groupBox1);
                HabilitarTexto(groupBox2);
                HabilitarTexto(groupBox3);
                HabilitarTexto(groupBox4);
                HabilitarTexto(groupBox5);
                HabilitarTexto(groupBox8);

            }

            else if(e.KeyCode == Keys.Escape)
                 {
                this.Close();
            }
        }
        private void btnNuevoRow_Click(object sender, EventArgs e)
        {
            try
            {

                frmModalDetalle frmps = new frmModalDetalle();
                frmps.FormParent = this;
                frmps.EstadoDet = 1;
                //frmps.pasard += new Frmco_modaloc_qry.pasar(ejecutarproducto);
                frmps.ShowDialog();
                //txtIdPedido.Focus();

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }