protected void btnSend_Click(object sender, EventArgs e)
        {

            lblError.Text = "";
            lblConfirm.Text = "";
            InterfazDAL_tticol125 idal = new InterfazDAL_tticol125();
            Ent_tticol125 obj = new Ent_tticol125();
            string strError = string.Empty;
            obj.paid = txtPalletId.Text.ToUpperInvariant();

            HttpContext.Current.Session["flag022"] = 0;
            HttpContext.Current.Session["flag042"] = 0;
            HttpContext.Current.Session["flag131"] = 0;
            divPrint.Visible = false;

            string retorno = string.Empty;


            decimal palletQuantity = 0;
            decimal status;
            string tableName = string.Empty;

            DataTable resultadoPaid = idal.vallidatePalletID(ref obj, ref strError);

            if (resultadoPaid.Rows.Count < 1) { retorno = PalletIDdoesntexists; }
            else
            {
                foreach (DataRow dr in resultadoPaid.Rows)
                {
                    status = Convert.ToDecimal(dr.ItemArray[8].ToString());
                    palletQuantity = Convert.ToDecimal(dr.ItemArray[3].ToString());
                    tableName = dr.ItemArray[0].ToString();

                    if (((tableName == "whcol131") || (tableName == "whcol130")) && (status != 3))
                    {
                        lblError.Text = PalletIDstatusdoesntallowadjustment;
                        return;
                    }
                    else if (((tableName == "ticol022") || (tableName == "ticol042")) && (status != 7))
                    {
                        lblError.Text = PalletIDstatusdoesntallowadjustment;
                        return;
                    }
                }
            }

            if (string.IsNullOrEmpty(txtPalletId.Text.Trim()))
            {
                //minlenght.Enabled = true;
                //minlenght.ErrorMessage = mensajes("Please Fill all the Required  Fields.");
                //minlenght.IsValid = false;

                //return;
            }
            DataTable resultado = idal.invGetPalletInfo(ref obj, ref strError);
            DataTable resultadoSerie = idal.invGetPalletInfoSerie(ref strError);

            if (resultado == null || resultado.Rows.Count == 0)
            {
                lblError.Text = PalletIDdoesntexists;
                return;
            }

            string palletId, item, warehouse, lot, location, quantity, dsca, unit, waredesc, machine, tbl, pono;

            if (resultado.Rows.Count == 1)
            {
                if (resultadoSerie.Rows.Count > 0)
                {
                    Session["emno"] = resultadoSerie.Rows[0]["EMNO"].ToString();
                    Session["cdis"] = resultadoSerie.Rows[0]["CDIS"].ToString();
                    lblReason.Text = resultadoSerie.Rows[0]["CDIS"].ToString() + " - " + resultadoSerie.Rows[0]["DSCA"].ToString();
                    lblCost.Text = resultadoSerie.Rows[0]["EMNO"].ToString() + " - " + resultadoSerie.Rows[0]["NAMA"].ToString();
                }
                else
                {
                    lblReason.Text = string.Empty;
                    lblCost.Text = string.Empty;
                }

                DataRow dr = resultado.Rows[0];
                tbl = dr.ItemArray[0].ToString();
                if (tbl.Trim() == "ticol022")
                {
                    HttpContext.Current.Session["flag022"] = 1;
                    HttpContext.Current.Session["flag131"] = 0;
                    HttpContext.Current.Session["flag042"] = 0;
                }
                else if (tbl.Trim() == "whcol131")
                {
                    HttpContext.Current.Session["flag022"] = 0;
                    HttpContext.Current.Session["flag131"] = 1;
                    HttpContext.Current.Session["flag042"] = 0;
                }
                else if (tbl.Trim() == "ticol042")
                {
                    HttpContext.Current.Session["flag022"] = 0;
                    HttpContext.Current.Session["flag131"] = 0;
                    HttpContext.Current.Session["flag042"] = 1;
                }

                palletId = dr.ItemArray[2].ToString();
                quantity = dr.ItemArray[3].ToString();
                item = dr.ItemArray[4].ToString();
                dsca = dr.ItemArray[5].ToString();
                unit = dr.ItemArray[6].ToString();
                warehouse = dr.ItemArray[7].ToString();
                waredesc = dr.ItemArray[8].ToString();
                lot = dr.ItemArray[10].ToString();
                location = dr.ItemArray[9].ToString();
                Pquantity = Convert.ToDouble(quantity);
                machine = dr.ItemArray[11].ToString();
                pono = dr.ItemArray[12].ToString();
                HttpContext.Current.Session["pono"] = pono;

                lblPalletId1Value.Text = palletId;
                lblItemValue.Text = item;
                lblItemDescValue.Text = dsca;
                lblWarehouseValue.Text = warehouse;
                lblWarehouseDescValue.Text = waredesc;
                lblLotValue.Text = lot;
                lblLocationValue.Text = location;
                lblQuantityValue.Text = quantity;
                lblUnitValue.Text = unit;
                lblUnitValue1.Text = unit;
                tblPalletInfo.Visible = true;
                btnSend.Visible = false;
                btnSave.Visible = true;
                lblMachine.Text = machine;
                generateDropDownReasonCodes();
                generateDropDownCostCenters();
                dropDownCostCenters.SelectedValue = Session["emno"].ToString();
                dropDownReasonCodes.SelectedValue = Session["cdis"].ToString();
                if (Session["emno"].ToString() == "DO3062" && Session["cdis"].ToString() == "CS1004")
                {
                    dropDownCostCenters.Visible = true;
                    dropDownReasonCodes.Visible = true;
                    lblReason.Visible = false;
                    lblCost.Visible = false;
                }
                else
                {
                    dropDownCostCenters.Visible = false;
                    dropDownReasonCodes.Visible = false;
                    lblReason.Visible = true;
                    lblCost.Visible = true;
                }
            }
        }