protected void rcmbFac_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
        {
            try
            {
                RadComboBox rcmbFac = (sender as RadComboBox);
                Telerik.Web.UI.GridTableCell tabla   = (Telerik.Web.UI.GridTableCell)rcmbFac.Parent;
                RadNumericTextBox            txtFact = tabla.FindControl("txtFact") as RadNumericTextBox;
                RadTextBox        txtCte             = tabla.FindControl("txtCte") as RadTextBox;
                RadNumericTextBox txtImporte         = tabla.FindControl("txtImporte") as RadNumericTextBox;

                Factura factura = new Factura();
                factura.Id_Cd  = this.sesion.Id_Cd_Ver;
                factura.Id_Emp = this.sesion.Id_Emp;
                if (txtFact.Text != string.Empty)
                {
                    factura.Id_Fac = Convert.ToInt32(txtFact.Text);
                }
                else
                {
                    factura.Id_Fac = 0;
                }

                CN_CapFactura CNCapFactura = new CN_CapFactura();
                try
                {
                    CNCapFactura.BuscaFacturaRuta(ref factura, sesion.Emp_Cnx);
                }
                catch (Exception ex)
                {
                    txtFact.Text    = "";
                    txtCte.Text     = "";
                    txtImporte.Text = "";
                    AlertaFocus(ex.Message, txtFact.ClientID);
                    return;
                }
                txtCte.Text     = factura.Cte_NomComercial;
                txtImporte.Text = factura.Fac_Importe.ToString();

                txtCte.ReadOnly     = true;
                txtImporte.ReadOnly = true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        protected void txtFac_TextChanged(object sender, EventArgs e)
        {
            try
            {
                RadNumericTextBox txtfac       = sender as RadNumericTextBox;
                RadComboBox       txtserie     = (txtfac.Parent.FindControl("rcbSerie") as RadComboBox);
                RadTextBox        rgCteNombre  = (txtfac.Parent.FindControl("txtCte") as RadTextBox);
                RadNumericTextBox rgtxtImporte = (txtfac.Parent.FindControl("txtImporte") as RadNumericTextBox);

                DataRow[] ar = dt_detalles.Select("Id_Fac='" + txtfac.Text + "' and Id_FacSerie='" + txtserie.Text + "'");

                if (ar.Length > 0)
                {
                    AlertaFocus("Esta factura ya ha sido asignada en esta ruta", txtfac.ClientID);
                    txtfac.Text       = "";
                    rgCteNombre.Text  = "";
                    rgtxtImporte.Text = "";
                    return;
                }
                Factura factura = new Factura();
                factura.Id_Cd  = this.sesion.Id_Cd_Ver;
                factura.Id_Emp = this.sesion.Id_Emp;
                factura.Id_Fac = Convert.ToInt32(txtfac.Text);
                CN_CapFactura CNCapFactura = new CN_CapFactura();
                try
                {
                    CNCapFactura.BuscaFacturaRuta(ref factura, sesion.Emp_Cnx);
                }
                catch (Exception ex)
                {
                    txtfac.Text       = "";
                    rgCteNombre.Text  = "";
                    rgtxtImporte.Text = "";
                    AlertaFocus(ex.Message, txtfac.ClientID);
                    return;
                }
                rgCteNombre.Text  = factura.Cte_NomComercial;
                rgtxtImporte.Text = (factura.Fac_Importe).ToString();
            }
            catch (Exception ex)
            {
                ErrorManager(ex, new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name);
            }
        }
        protected void rgDetalles_InsertCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
        {
            try
            {
                GridEditableItem editedItem = e.Item as GridEditableItem;

                RadNumericTextBox txtFact = editedItem.FindControl("txtFact") as RadNumericTextBox;
                RadComboBox       cmbFac  = editedItem.FindControl("rcbSerie") as RadComboBox;
                if (txtFact.Text == string.Empty || cmbFac.Text == string.Empty)
                {
                    this.Alerta("Seleccione primero una factura");
                    this.rgDetalles.Columns.FindByUniqueName("EditCommandColumn").Visible = true;
                    return;
                }
                else
                {
                    Factura factura = new Factura();
                    factura.Id_Cd  = this.sesion.Id_Cd_Ver;
                    factura.Id_Emp = this.sesion.Id_Emp;
                    factura.Id_Fac = Convert.ToInt32(txtFact.Text);
                    CN_CapFactura CNCapFactura = new CN_CapFactura();
                    CNCapFactura.BuscaFacturaRuta(ref factura, sesion.Emp_Cnx);

                    DataRow[] ar = dt_detalles.Select("Id_Fac='" + factura.Id_Fac + "' and Id_FacSerie='" + factura.Id_FacSerie.Replace(factura.Id_Fac.ToString(), "") + "'");

                    if (ar.Length > 0)
                    {
                        Alerta("Esta factura ya ha sido asignada en esta ruta");
                    }
                    else
                    {
                        dt_detalles.Rows.Add(new object[] { factura.Id_Fac, factura.Id_FacSerie.Replace(factura.Id_Fac.ToString(), ""), factura.Cte_NomComercial, factura.Fac_Importe });
                    }

                    this.rgDetalles.Columns.FindByUniqueName("EditCommandColumn").Visible = false;
                }
            }
            catch (Exception ex)
            {
                ErrorManager(ex, new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name);
                e.Canceled = true;
            }
        }