public static string validaInfo(string valor, string tipo)
        {
            InterfazDAL_ttwhcol016 idal = new InterfazDAL_ttwhcol016();
            Ent_ttwhcol016         obj  = new Ent_ttwhcol016();
            string    strError          = string.Empty;
            string    retorno           = string.Empty;
            DataTable resultado         = new DataTable();
            string    strSecondVal      = string.Empty;

            if (tipo == "1") // Bodega
            {
                obj.cwar  = valor.Trim().ToUpperInvariant();
                resultado = idal.TakeMaterialInv_verificaBodega_Param(ref obj, ref strError);
            }
            if (tipo == "2") // Zona
            {
                obj.zone  = valor.Trim().ToUpperInvariant();
                resultado = idal.TakeMaterialInv_verificaZona_Param(ref obj, ref strError);
                if (resultado.Rows.Count > 0)
                {
                    int consecutivo = 0;
                    consecutivo  = idal.TakeMaterialInv_verificaConsLabel_Param(ref obj, ref strError);
                    strSecondVal = "|" + consecutivo.ToString().Trim();

                    if (consecutivo < 1)
                    {
                        strError = _idioma == "INGLES" ? "Sequence Zone " + valor + " doesn't exist. Cannot Continue"
                            : "Secunecia de zona " + valor + " no existe, no se puede continuar.";
                    }
                }
            }
            if (tipo == "3") // Item
            {
                obj.item  = valor.Trim().ToUpperInvariant();
                resultado = idal.TakeMaterialInv_verificaItem_Param(ref obj, ref strError);
                if (resultado.Rows.Count <= 0)
                {
                    strError = _idioma == "INGLES" ? "Item code doesn´t exist. Cannot continue" : "Codigo de articulo no existe. No se puede continuar";
                }
            }
            if (tipo == "4") // Lote
            {
                obj.clot  = valor.Trim().ToUpperInvariant();
                resultado = idal.TakeMaterialInv_verificaLote_Param(ref obj, ref strError);
                if (resultado.Rows.Count <= 0)
                {
                    strError = _idioma == "INGLES" ? "Lot Code doesn´t exist. Cannot Continue" : "Codigo de lote no existe. No se puede continuar";
                }
            }



            // Validar si el numero de orden trae registros
            if (strError != string.Empty)
            {
                return("BAAN: " + strError);
            }

            if (resultado.Rows.Count > 0)
            {
                retorno = resultado.Rows[0]["DESCRIPCION"].ToString();

                if (tipo == "3")
                {
                    retorno = resultado.Rows[0]["DESCRIPCION"].ToString().Trim() + "|" +
                              resultado.Rows[0]["UNIDAD"].ToString().Trim() + "|" +
                              resultado.Rows[0]["LOTE"].ToString().Trim();
                }
            }

            return(retorno + strSecondVal);
        }
        protected void btnSend_Click(object sender, EventArgs e)
        {
            //if ((string.IsNullOrEmpty(txtCwar.Text)) ||
            if ((string.IsNullOrEmpty(txtItem.Text)) ||
                (string.IsNullOrEmpty(txtQuantity.Text)) ||
                (string.IsNullOrEmpty(txtZone.Text)))
            {
                lblError.Text = mensajes("formempty");
                txtItem.Focus();
                return;
            }

            if (hi_indLote.Value == "1" && string.IsNullOrEmpty(txtLote.Text.Trim()))
            {
                lblError.Text = mensajes("lotempty");
                txtLote.Focus();
                return;
            }

            // Debe refrescar el consecutivo de la etiqueta

            obj.zone = txtZone.Text.Trim().ToUpperInvariant();
            int consecutivo = idal.TakeMaterialInv_verificaConsLabel_Param(ref obj, ref strError);

            hidden.Value = consecutivo.ToString();;

            obj.cwar     = string.IsNullOrEmpty(txtCwar.Text.Trim()) ? " " : txtCwar.Text.ToUpperInvariant();
            obj.zone     = txtZone.Text.ToUpperInvariant();
            obj.item     = txtItem.Text.ToUpperInvariant();
            obj.clot     = obj.clot = string.IsNullOrEmpty(txtLote.Text.Trim()) ? " " : txtLote.Text.ToUpperInvariant();
            obj.qtyr     = Decimal.Parse(txtQuantity.Text, System.Globalization.CultureInfo.InvariantCulture); //Convert.ToDecimal(txtQuantity.Text);
            obj.refcntd  = 0;
            obj.refcntu  = 0;
            obj.logn     = Session["user"].ToString();
            obj.labl     = obj.zone.Trim().ToUpperInvariant() + "-" + hidden.Value.PadLeft(5, '0');
            hidden.Value = (Convert.ToInt32(hidden.Value) + 1).ToString();

            List <Ent_ttwhcol016> parameterCollection = new List <Ent_ttwhcol016>();

            parameterCollection.Add(obj);
            //            CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture;
            //            lblError.Text = currentCulture.NumberFormat.CurrencyDecimalSeparator.ToString();

            int retorno = idal.insertarRegistro(ref parameterCollection, ref strError);

            // Buscar en web config cantidad de reintentos para guardar
            int  contador;
            bool convert = int.TryParse(ConfigurationManager.AppSettings["numberRetryOnSave"].ToString(), out contador);

            if (!convert)
            {
                contador = 1;
            }

            int cantidad = 0;

            // reintar tantas veces como se haya especificado
            while (retorno < 0 && cantidad < contador)
            {
                retorno = idal.insertarRegistro(ref parameterCollection, ref strError);
                cantidad++;
            }


            if (retorno < 1)
            {
                lblError.Text = mensajes("errorsave");
                return;
            }

            txtCwar.Text     = string.Empty;
            lblCwar.Text     = string.Empty;
            txtItem.Text     = string.Empty;
            lblItem.Text     = string.Empty;
            txtLote.Text     = string.Empty;
            lblLotCode.Text  = string.Empty;
            txtQuantity.Text = string.Empty;
            lblUnity.Text    = string.Empty;
            //txtZone.Text = string.Empty;


            DataTable resultado = idal.TakeMaterialInv_listaConsLabel_Param(ref obj, ref strError);
            DataRow   reg       = resultado.Rows[0];

            //Session["FilaImprimir"] = reg;
            //Session["descItem"] = hi_descItem.Value;
            //Session["unidad"] = hi_unityItem.Value;

            Session["MaterialDesc"] = reg["T$ITEM"];
            Session["codeMaterial"] = reg["T$ITEM"].ToString().Trim();
            Session["codePaid"]     = reg["T$LABL"].ToString().Trim();
            Session["Lot"]          = obj.clot;
            Session["Quantity"]     = obj.qtyr + " " + hi_unityItem.Value;
            Session["Date"]         = DateTime.Now.ToString("MM/dd/yyyy");
            Session["Pallet"]       = reg["T$LABL"].ToString().Trim();
            Session["Machine"]      = idal022.getMachine(obj.clot, reg["T$ITEM"].ToString().Trim(), ref strError);;
            Session["Operator"]     = Session["user"].ToString();
            Session["Reprint"]      = "no";

            StringBuilder script = new StringBuilder();

            if (HttpContext.Current.Session["navigator"].ToString() == "EDG")
            {
                script.Append("myLabelFrame = document.getElementById('myLabelFrame'); myLabelFrame.src ='../Labels/RedesingLabels/6InventoryLabelME.aspx'; ");
            }
            else
            {
                script.Append("myLabelFrame = document.getElementById('myLabelFrame'); myLabelFrame.src ='../Labels/RedesingLabels/6InventoryLabel.aspx'; ");
            }
            ScriptManager.RegisterStartupScript(this, this.GetType(), "printTag", script.ToString(), true);

            //StringBuilder script = new StringBuilder();
            //script.Append("ventanaImp = window.open('../Labels/whInvPrintLabelPhysical.aspx', ");
            //script.Append("'ventanaImp', 'menubar=0,resizable=0,width=580,height=450');");
            //script.Append("ventanaImp.moveTo(30, 0);");
            ////script.Append("setTimeout (ventanaImp.close(), 20000);");
            //ScriptManager.RegisterStartupScript(this, this.GetType(), "printTag", script.ToString(), true);
        }