protected void BtnEntregar_Click(object sender, EventArgs e)
        {
            Page.Title = ViewState["PageTit"].ToString().Trim();
            Idioma     = (DataTable)ViewState["TablaIdioma"];
            DataRow[] Result;
            string    VbTieneReg = "N";

            if (TxtObserv.Text.Trim().Equals(""))
            {
                Result = Idioma.Select("Objeto= 'MstrMens22'");
                foreach (DataRow row in Result)
                {
                    ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert('" + row["Texto"].ToString() + "');", true);
                }                                                                                                                                       //
                return;
            }
            if (DdlCliente.Text.Trim().Equals(""))
            {
                Result = Idioma.Select("Objeto= 'MensSalConsg01'");
                foreach (DataRow row in Result)
                {
                    ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert('" + row["Texto"].ToString() + "');", true);
                }                                                                                                                                       //Debe seleccionar un cliente.
                return;
            }
            List <CsInsertElementoAlmacen> ObjDetalle = new List <CsInsertElementoAlmacen>();

            foreach (GridViewRow Row in GrdDetalle.Rows)
            {
                string VbSn, VblLote;


                CheckBox CkbSelP = Row.FindControl("CkbSelP") as CheckBox;

                if (CkbSelP.Checked == true)
                {
                    VbTieneReg = "S";
                    switch (GrdDetalle.DataKeys[Row.RowIndex].Values["IdentificadorElem"].ToString().Trim())
                    {
                    case "SN":
                        VbSn = (Row.FindControl("LblSn") as Label).Text.Trim(); VblLote = "";
                        break;

                    case "LOTE":
                        VbSn = ""; VblLote = (Row.FindControl("LblSn") as Label).Text.Trim();
                        break;

                    default:
                        VbSn = ""; VblLote = "";
                        break;
                    }
                    var TypDetalle = new CsInsertElementoAlmacen()
                    {
                        IdIE             = Convert.ToInt32(0),
                        CodElemento      = GrdDetalle.DataKeys[Row.RowIndex].Values["CodElemento"].ToString().Trim(),
                        CodReferencia    = (Row.FindControl("LblRef") as Label).Text.Trim(),
                        PN               = (Row.FindControl("LblPn") as Label).Text.Trim(),
                        SN               = VbSn.Trim(),
                        Lote             = VblLote.Trim(),
                        CodTipoElem      = GrdDetalle.DataKeys[Row.RowIndex].Values["CodTipoElem"].ToString().Trim(),
                        Identificador    = GrdDetalle.DataKeys[Row.RowIndex].Values["IdentificadorElem"].ToString().Trim(),
                        Descripcion      = (Row.FindControl("LblDesc") as Label).Text.Trim(),
                        Cantidad         = Convert.ToDouble((Row.FindControl("LblCant") as TextBox).Text.Trim()),
                        CantidadAnt      = Convert.ToDouble((Row.FindControl("LblCantAct") as Label).Text.Trim()),
                        Valor            = Convert.ToDouble(0),
                        CodUndMed        = GrdDetalle.DataKeys[Row.RowIndex].Values["CodUndMed"].ToString().Trim(),
                        IdAlmacen        = Convert.ToInt32(GrdDetalle.DataKeys[Row.RowIndex].Values["CodIdAlmacen"].ToString().Trim()),
                        CodBodega        = GrdDetalle.DataKeys[Row.RowIndex].Values["CodBodega"].ToString().Trim(),
                        CodShippingOrder = "",
                        Posicion         = "0",
                        CodAeronave      = Convert.ToInt32(0),
                        Matricula        = "",
                        CCosto           = "",
                        AfectaInventario = Convert.ToInt32(0),
                        CostoImportacion = Convert.ToInt32(0),
                        CodTercero       = DdlCliente.Text.Trim(),
                        Consignacion     = Convert.ToInt32(0),
                        CodIdUbicacion   = Convert.ToInt32(GrdDetalle.DataKeys[Row.RowIndex].Values["CodIdUbicacion"].ToString().Trim()),
                        FechaVence       = null,
                        Observacion      = TxtObserv.Text.Trim(),
                        Proceso          = "0111", // Salida consignacion
                        IdDetPropHk      = Convert.ToInt32(0),
                        IdPPt            = Convert.ToInt32(0),
                        Accion           = "SALIDA",
                    };
                    ObjDetalle.Add(TypDetalle);
                }
            }
            if (VbTieneReg.Equals("S"))
            {
                CsInsertElementoAlmacen ClaseIEA = new CsInsertElementoAlmacen();
                ClaseIEA.FormOrigen(ViewState["PFileName"].ToString());
                ClaseIEA.Alimentar(ObjDetalle);

                string Mensj = ClaseIEA.GetMensj();
                if (!Mensj.Equals(""))
                {
                    string VbPNMen = ClaseIEA.GetPn().Trim().Equals("") ? "" : "[P/N: " + ClaseIEA.GetPn().Trim() + "]";
                    string VbSNMen = ClaseIEA.GetSn().Trim().Equals("") ? "" : "[S/N: " + ClaseIEA.GetSn().Trim() + "]";
                    string VbLot   = ClaseIEA.GetLote().Trim().Equals("") ? "" : "[LT/N: " + ClaseIEA.GetLote().Trim() + "]";
                    Result = Idioma.Select("Objeto= '" + Mensj.ToString().Trim() + "'");
                    foreach (DataRow row in Result)
                    {
                        Mensj = row["Texto"].ToString().Trim();
                    }
                    ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert('" + Mensj + "  " + VbPNMen + "  " + VbSNMen + "  " + VbLot + "');", true);
                    return;
                }
                TxtObserv.Text        = ""; DdlBodega.Text = ""; DdlCliente.Text = ""; BtnEntregar.Enabled = false;
                GrdDetalle.DataSource = null; GrdDetalle.DataBind();
            }
        }
        protected void BtnIngresar_Click(object sender, EventArgs e)
        {
            Idioma     = (DataTable)ViewState["TablaIdioma"];
            DSTPpal    = (DataSet)ViewState["DSTPpal"];
            TblDetalle = (DataTable)ViewState["TblDetalle"];
            DataRow[] Result;
            string    VblPn = "", VblSn = "";

            if (TxtObserv.Text.Trim().Equals(""))
            {
                Result = Idioma.Select("Objeto= 'MstrMens22'");
                foreach (DataRow row in Result)
                {
                    ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert('" + row["Texto"].ToString() + "');", true);
                }                                                                                                                                       //
                return;
            }
            List <CsInsertElementoAlmacen> ObjDetalle = new List <CsInsertElementoAlmacen>();

            foreach (DataRow Row in TblDetalle.Rows)
            {
                var TypDetalle = new CsInsertElementoAlmacen()
                {
                    IdIE             = Convert.ToInt32(0),
                    CodElemento      = "",
                    CodReferencia    = Row["CodReferencia"].ToString().Trim(),
                    PN               = Row["PN"].ToString(),
                    SN               = Row["SN"].ToString(),
                    Lote             = "",
                    CodTipoElem      = Row["CodTipoElem"].ToString().Trim(),
                    Identificador    = Row["Identificador"].ToString().Trim(),
                    Descripcion      = Row["Descripcion"].ToString().Trim(),
                    Cantidad         = Convert.ToDouble(Row["Cantidad"].ToString().Trim()),
                    CantidadAnt      = Convert.ToDouble(0),
                    Valor            = Convert.ToDouble(0),
                    CodUndMed        = "",
                    IdAlmacen        = Convert.ToInt32(Row["IdAlmacen"].ToString().Trim()),
                    CodBodega        = Row["CodBodega"].ToString().Trim(),
                    CodShippingOrder = "",
                    Posicion         = "0",
                    CodAeronave      = 0,
                    Matricula        = "",
                    CCosto           = "",
                    AfectaInventario = Convert.ToInt32(0),
                    CostoImportacion = Convert.ToInt32(0),
                    CodTercero       = "",
                    Consignacion     = Convert.ToInt32(1),
                    CodIdUbicacion   = Convert.ToInt32(0),
                    FechaVence       = null,
                    Observacion      = TxtObserv.Text.Trim(),
                    Proceso          = "RecElemPpt",
                    IdDetPropHk      = Convert.ToInt32(0),
                    IdPPt            = Convert.ToInt32(0),
                    Accion           = "ENTRADA",
                };
                ObjDetalle.Add(TypDetalle);
            }
            CsInsertElementoAlmacen ClaseIEA          = new CsInsertElementoAlmacen();

            ClaseIEA.FormOrigen(ViewState["PFileName"].ToString());
            ClaseIEA.Alimentar(ObjDetalle);

            string Mensj = ClaseIEA.GetMensj();

            if (!Mensj.Equals(""))
            {
                VblPn  = ClaseIEA.GetPn().Trim().Equals("") ? "" : "  [P/N: " + ClaseIEA.GetPn().Trim() + "]  ";
                VblSn  = ClaseIEA.GetSn().Trim().Equals("") ? "" : " [S/N: " + ClaseIEA.GetSn().Trim() + "]";
                Result = Idioma.Select("Objeto= '" + Mensj.ToString().Trim() + "'");
                foreach (DataRow row in Result)
                {
                    Mensj = row["Texto"].ToString().Trim();
                }
                ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert('" + Mensj + VblPn + VblSn + "');", true);
                return;
            }
            TxtObserv.Text = "";
            TblDetalle.Clear();
            BindDDetTmp();
        }