private void dgColor_DoubleClick(object sender, EventArgs e)
        {
            if (lblNum.Text == "0")
                {

                    MessageBox.Show("No hay registros", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtdescripcion.Focus();
                }
                else
                {

                    EColor col = new EColor();
                    col.RowNumber = Convert.ToInt16(dgColor.CurrentRow.Cells["RowNumber"].Value);
                    col.Id_color = dgColor.CurrentRow.Cells["id_color"].Value.ToString();
                    col.Ds_color = dgColor.CurrentRow.Cells["ds_color"].Value.ToString();
                    col.Id_vtipcolor = dgColor.CurrentRow.Cells["id_vtipcolor"].Value.ToString();
                    col.Fe_creacion = Convert.ToDateTime(dgColor.CurrentRow.Cells["fe_creacion"].Value);
                    col.Id_cartacol = dgColor.CurrentRow.Cells["id_cartacol"].Value.ToString();
                    col.Nu_opcion = dgColor.CurrentRow.Cells["nu_opcion"].Value.ToString();

                    pasard(col);
                    this.Dispose();

            }
        }
        public static DataSet ColorFill(EColor col)
        {
            DBAccess db = new DBAccess();

            db.AddParameter("@psintypesel", col.psintypesel);
            db.AddParameter("@pidEmpresa", col.IdEmpresa);
            db.AddParameter("@pid_color", col.Id_color);
            db.AddParameter("@pds_color", col.Ds_color);
            return db.ExecuteDataSet("MG_Color_qry01");
        }
        public static void Color_mnt(EColor CL)
        {
            DBAccess db = new DBAccess();

            db.AddParameter("@pid_color", CL.Id_color);
            db.AddParameter("@pidEmpresa", CL.IdEmpresa);
            db.AddParameter("@pds_color", CL.Ds_color);
            db.AddParameter("@pid_vtipcolor", CL.Id_vtipcolor);
            db.AddParameter("@pfe_creacion", CL.Fe_creacion);
            db.AddParameter("@pid_cartacol", CL.Id_cartacol);
            db.AddParameter("@pnu_opcion", CL.Nu_opcion);
            db.AddParameter("@pid_ucrearec", CL.Id_ucrearec);
            db.ExecuteNonQuery("MG_Color_mnt01");
        }
        public static List<Dato> ObtenerDatoColor(EColor c)
        {
            List<Dato> _lista = new List<Dato>();

            DBAccess db = new DBAccess();

            db.AddParameter("@psintypesel", c.psintypesel);
            db.AddParameter("@pidEmpresa", c.IdEmpresa);
            db.AddParameter("@pid_color", c.Id_color);
            db.AddParameter("@pds_color", c.Ds_color);

            IDataReader reader = db.ExecuteReader("MG_Color_qry01");

            while (reader.Read())
            {
                Dato _dato = new Dato();

                _dato.id = reader["id_color"].ToString();
                _dato.desc = reader["ds_color"].ToString();
                _lista.Add(_dato);
            }
            return _lista;
        }
        private void ListarColor()
        {
            try
            {
                EColor col = new EColor();
                if (psintypesel == 0)
                {
                    col.psintypesel = 0;
                    col.IdEmpresa = wfChgEmpPer.datos.idEmpresa;
                    col.Id_color = txtCodigo.Text;
                    col.Ds_color = txtdescripcion.Text;
                    DataSet ds = BColor.GetListFill(col);
                    dgColor.DataSource = ds.Tables[0];
                    lblNum.Text = Convert.ToInt16(dgColor.RowCount).ToString();
                }
                else if (psintypesel == 1)
                {
                    col.psintypesel = 1;
                    col.IdEmpresa = wfChgEmpPer.datos.idEmpresa;
                    col.Id_color = txtCodigo.Text;
                    col.Ds_color = txtdescripcion.Text;
                    DataSet ds = BColor.GetListFill(col);
                    dgColor.DataSource = ds.Tables[0];
                    lblNum.Text = Convert.ToInt16(dgColor.RowCount).ToString();
                }

            }
            catch (Exception ex)
            {
                ex.ToString();
            }
        }
 public static void TJ_Color_mnt04(EColor CL)
 {
     DColor.Color_mnt(CL);
 }
 public static List<Dato> ObtenerDatoColor(EColor c)
 {
     return DColor.ObtenerDatoColor(c);
 }
 public static DataSet GetListFill(EColor col)
 {
     return DColor.ColorFill(col);
 }
 public void ejecutarColor(EColor col)
 {
     txtidColor.Text = col.Id_color;
     lblColor.Text = col.Ds_color;
 }
        private void txtidcolor_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == Convert.ToChar(Keys.Enter))
             {
                 txtidcolor.Text = txtidcolor.Text.PadLeft(9, '0');

                 EColor per = new EColor();
                 per.psintypesel = 1;
                 per.IdEmpresa = wfChgEmpPer.datos.idEmpresa;
                 per.Id_color = txtidcolor.Text;
                 per.Ds_color = "";

                 List<Dato> oListDato = BColor.ObtenerDatoColor(per);

                 if (oListDato.Count > 0)
                 {
                     lblcolor.Text = oListDato[0].desc;

                     txtidcliente.SelectionStart = 0;
                     txtidcliente.SelectionLength = txtidcliente.Text.Length;
                     txtidcliente.Focus();
                 }
                 else
                 {
                     MessageBox.Show("Color no Existe", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                     txtidcolor.Clear();
                     lblcolor.Text="";
                     txtidcolor.Focus();
                 }

             }
        }
        private void ListarColor()
        {
            //try
            //{
                EColor col = new EColor();
                if (psintypesel == 0)
                {
                    col.psintypesel = 0;
                    col.Id_color = txtidcolor.Text;
                    col.Ds_color = txtdsColor.Text;
                    col.IdEmpresa = wfChgEmpPer.datos.idEmpresa;

                    DataSet ds = BColor.GetListFill(col);
                    dgvDetalle_.DataSource = ds.Tables[0];
                    nuItem.Text = Convert.ToInt16(dgvDetalle_.RowCount).ToString();
                }
                else if (psintypesel == 1)
                {
                    col.psintypesel = 1;
                    col.Id_color = txtidcolor.Text;
                    col.Ds_color = txtdsColor.Text;
                    col.IdEmpresa = wfChgEmpPer.datos.idEmpresa;

                    DataSet ds = BColor.GetListFill(col);
                    dgvDetalle_.DataSource = ds.Tables[0];
                    nuItem.Text = Convert.ToInt16(dgvDetalle_.RowCount).ToString();
                }

            //}
            //catch (Exception ex)
            //{
            //    ex.ToString();
            //}
        }
        private void Grabar()
        {
            try
            {
                EColor CL = new EColor();
                DialogResult result = MessageBox.Show("Seguro que desea Grabar?", "Grabar", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                if (result == DialogResult.OK)
                {
                    if (txtidcolor.Text == "")
                    {
                        List<Dato> oListDato = BColor.Color_qry06(wfChgEmpPer.datos.idEmpresa);
                        if (oListDato.Count > 0)
                        {
                            txtidcolor.Text = oListDato[0].id;
                            CL.Id_color = txtidcolor.Text;
                        }

                    }
                    else
                    {
                        CL.Id_color = txtidcolor.Text;
                    }

                    CL.IdEmpresa = wfChgEmpPer.datos.idEmpresa;
                    CL.Ds_color = txtdsColor.Text.ToUpper();
                    CL.Id_vtipcolor = "000";
                    CL.Fe_creacion = txtfecha.Value;
                    CL.Id_cartacol = "0000000";
                    CL.Nu_opcion = "0";
                    CL.Id_ucrearec = frmLogin.d.id.ToLower();
                    BColor.TJ_Color_mnt04(CL);
                    MessageBox.Show("Datos Grabados", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        private void Nuevo()
        {
            HabilitarTexto(groupBox1);
            HabilitarTexto(groupBox2);
            HabilitarTexto(groupBox3);
            HabilitarTexto(groupBox4);
            HabilitarTexto(groupBox5);
            HabilitarTexto(groupBox8);

            txt_idTejido.Text = "";
            txt_nuFicha.Text = "";

            Limpiar(groupBox1);
            Limpiar(groupBox2);
            Limpiar(groupBox3);
            Limpiar(groupBox4);
            Limpiar(groupBox5);
            Limpiar(groupBox8);

            //cb_Mercado.SelectedIndex = -1;
            //cb_Destino.SelectedIndex = -1;
            cb_InfTecCrudo_ancho.SelectedIndex = -1;

            txt_infTecCruda_cant.Text = string.Format("{0:##,##0.0000}", 0);
            txt_InfTecCrudo_densidad.Text = string.Format("{0:##,##0.0000}", 0);
            txt_InfTecCrudo_rendim.Text = string.Format("{0:##,##0.0000}", 0);
            txt_InfTecAcab_desnsi.Text = string.Format("{0:##,##0.0000}", 0);
            txt_InfTecAcab_rendim.Text = string.Format("{0:##,##0.0000}", 0);
            txt_encogi_largo.Text = string.Format("{0:##,##0.0000}", 0);
            txt_encog_ancho.Text = string.Format("{0:##,##0.0000}", 0);
            txt_rev_porc.Text = string.Format("{0:##,##0.0000}", 0);
            txt_infTecCruda_cant.Text = string.Format("{0:##,##0.0000}", 0);
            txt_merma_porc.Text = string.Format("{0:##,##0.0000}", 0);

            txt_costo_teñido.Text = string.Format("{0:##,##0.0000}", 0);
            txtdiam.Text = string.Format("{0:##,##0.0000}", 0);
            txtgalga.Text = string.Format("{0}", 0);
            txtsistTrab.Text = string.Format("{0}", 0);
            txtsistAnul.Text = string.Format("{0}", 0);
            txt_merma_porc.Text = string.Format("{0:##,##0.0000}", 0);
            txtrpm.Text = string.Format("{0}", 0);
            txtpeso.Text = string.Format("{0:##,##0.0000}", 0);
            txt_InfTecAcab_ancho.Text = string.Format("{0:##,##0.0000}", 0);

            txtReqAcabAnch.Text = string.Format("{0:##,##0.0000}", 0);
            txtReqAcabDens.Text = string.Format("{0:##,##0.0000}", 0);
            txtPlatina.Text = string.Format("{0:##,##0.0000}", 0);

            txt_nuMuestra.Text = string.Format("{0000000000}", 0);
            txt_Nu_GT.Text = string.Format("{0000000000}", 0);
            txt_Nu_Regulacion.Text = string.Format("{0000000000}", 0);
            lblColor.Text = "";

            txtIdColor.Text = txtIdColor.Text.PadLeft(9, '0');

            //---------------------------------------------------------------------
            EColor per = new EColor();
            per.psintypesel = 1;
            per.IdEmpresa = wfChgEmpPer.datos.idEmpresa;
            per.Id_color = "000000000";
            per.Ds_color = "";

            List<Dato> oListDato = BColor.ObtenerDatoColor(per);

            if (oListDato.Count > 0)
            {
                lblColor.Text = oListDato[0].desc;

                txt_costo_teñido.SelectionStart = 0;
                txt_costo_teñido.SelectionLength = txt_costo_teñido.Text.Length;
                txt_costo_teñido.Focus();
            }
               //------------------------------------------------------------------------------------------------------------
            this.ActiveControl = txt_idTejido;
            txt_idTejido.Focus();

            btnBuscTejido.Enabled = true;
            btn_cliente.Enabled = true;
            btnBusColor.Enabled = true;

            txtBuscarFicha.Clear();
            txtBuscarnuTF.Clear();
            txtBuscarTejido.Clear();
            txtBuscarTfRef.Clear();

            dgDetalle.Rows.Clear();
            dgTJLM.Rows.Clear();
            dgProcesos.Rows.Clear();
            dgTempDetProc.Rows.Clear();
        }