private void ValidaProducto()
        {
            if (productid.Text.Trim().Length == 13)
            {
                var BL = new tb_me_productosBL();
                var BE = new tb_me_productos();
                var dt = new DataTable();

                BE.moduloid = modulo;
                BE.productid = productid.Text.Trim();

                dt = BL.GetAll(EmpresaID, BE).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    lineaid.Text = dt.Rows[0]["lineaid"].ToString().Trim();
                    lineaname.Text = dt.Rows[0]["lineaname"].ToString().Trim();
                    grupoid.Text = dt.Rows[0]["grupoid"].ToString().Trim();
                    gruponame.Text = dt.Rows[0]["gruponame"].ToString().Trim();
                    subgrupoid.Text = dt.Rows[0]["subgrupoid"].ToString().Trim();
                    subgruponame.Text = dt.Rows[0]["subgruponame"].ToString().Trim();
                    productid.Text = dt.Rows[0]["productid"].ToString().Trim();
                    productname.Text = dt.Rows[0]["productname"].ToString().Trim();
                }
                else
                {
                    productid.Text = string.Empty;
                    productname.Text = string.Empty;
                }
            }
            else
            {
                productid.Text = string.Empty;
                productname.Text = string.Empty;
            }
        }
        private void btn_busqueda_Click(object sender, EventArgs e)
        {
            try
            {
                tb_me_productosBL BL = new tb_me_productosBL();
                tb_me_productos BE = new tb_me_productos();
               // DataTable TablaProducto = new DataTable();

                BE.moduloid = modulo;
                BE.productname = txt_criterio.Text.Trim().ToUpper();

                Tablaproducto = BL.GetAll(EmpresaID, BE).Tables[0];
                if (Tablaproducto.Rows.Count > 0)
                {
                    btn_imprimir.Enabled = true;
                    dgb_productos.DataSource = Tablaproducto;
                    //dgb_productos.Rows[0].Selected = false;
                    //dgb_productos.Focus();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void Llenar_Datos()
        {
            if (cbo_moduloides.SelectedIndex != -1 &&
                cbo_moduloides.SelectedValue.ToString() != "0000" &&
                cbo_moduloides.SelectedValue.ToString() != "0200")
            {
                var BE = new tb_me_productos();
                var BL = new tb_me_productosBL();

                BE.moduloid = cbo_moduloides.SelectedValue.ToString();
                BE.productname = txtbusqueda.Text.Trim();
                BE.filtro = "4";

                Tablaproducto = BL.GetAll(EmpresaID, BE).Tables[0];
                if (Tablaproducto.Rows.Count > 0)
                {
                    MDI_dgb_productos.DataSource = Tablaproducto;
                }
                else
                {
                    MDI_dgb_productos.DataSource = Tablaproducto;
                }
            }
            else
            {
            }
        }
        private void btn_excel_Click(object sender, EventArgs e)
        {
            var BL = new tb_me_productosBL();
            var BE = new tb_me_productos();
            var TablaMov_ordprod = new DataTable();

            BE.moduloid = modulo.Trim();
            BE.filtro = "2";

            TablaMov_ordprod = BL.GetAll(VariablesPublicas.EmpresaID.ToString(), BE).Tables[0];
            if (TablaMov_ordprod.Rows.Count > 0)
            {
                ExportarExcel(TablaMov_ordprod);
            }
        }
        private void btn_CargarProductos_Click(object sender, EventArgs e)
        {
            var BL = new tb_me_productosBL();
            var BE = new tb_me_productos();

            BE.moduloid = modulo.ToString();
            BE.filtro = "3";

            TablaListaPrecios = BL.GetAll(EmpresaID, BE).Tables[0];

            if (TablaListaPrecios.Rows.Count > 0)
            {
                dgb_listaPrecios.DataSource = TablaListaPrecios;
                btn_exportar.Enabled = true;
                btn_CargarProductos.Enabled = false;
                btn_importar.Enabled = false;
                TablaListaPrecios.AcceptChanges();
                MessageBox.Show("Carga de Productos Completada...!!!");
            }
        }