private void CargarReporte(int id_remate)
    {
      try
      {
        if (id_remate != 0)
        {
          DataSet ds = new bf_re_remates().GetActaRemateReport(id_remate);
          if (ds.Tables.Count != 0)
          {
            ReportDataSource data = new ReportDataSource("ds_acta_remate", ds.Tables[0]);
            ReportDataSource datasource = data;

            //rpt_acta_remate.LocalReport.DataSources.Clear();
            rpt_acta_remate.LocalReport.DataSources.Add(datasource);
          }
          else
          {
            Mensajes.Error("No se encontraron Registros.");
          }
        }
        else
        {
          Mensajes.Error("No se encuentra el ID para este Remate");
        }
      }
      catch (Exception ex)
      {
        Mensajes.Error(ex.Message);
      }
    }
    protected void CmbRemates_OnReadData(object sender, StoreReadDataEventArgs e)
    {
      try
      {
        int start = e.Start;
        int limit = NumInt.Init(e.Parameters.GetParameter("limit").Value);
        limit = limit == 0 ? e.Limit : limit;
        int page = (start / limit) + 1;

        Nomina<co_re_remates_no> data = null;
        co_re_remates_no Nomina = new co_re_remates_no();
        Nomina.Pagina = page;
        Nomina.RegistrosPorPaginas = e.Limit;
        Nomina.ColumnaOrden = e.Sort[0].Property;
        Nomina.OrdenColumna = (FwpServerControls.FwpDataGridDataBound.Orden)Enum.Parse(typeof(FwpServerControls.FwpDataGridDataBound.Orden), e.Sort[0].Direction.ToString(), true);


        if (hid_id_remate.Text != @"")
        {
          Nomina.id_remate = int.Parse(hid_id_remate.Text);
          data = new bf_re_remates().GetNomina(Nomina);
        }
        else
        {
          Nomina.id_remateEstadoWeb = Constantes.ESTADO_REMATE_PUBLICADO;
          Nomina.id_rematetipo = ID_REMATETIPO;
          Nomina.id_familia = Constantes.FAMILIA_PROPIEDADES;
          data = new bf_re_remates().GetNominaAgrupadosDisponibles(Nomina);
        }
        IList<object> lista = new List<object>();


        foreach (co_re_remates_no no in data.DataSource)
        {
          lista.Add(new
          {
            id_remate = no.id_remate,
            rem_nombre = no.rem_nombre
          });
        }

        strCmbRemates.DataSource = lista;
        strCmbRemates.PageSize = limit;
        PageProxy pageProxy = strCmbRemates.Proxy[0] as PageProxy;
        if (pageProxy != null) pageProxy.Total = data.Registros;
        strCmbRemates.DataBind();

        if (hid_id_remate.Text != @"")
        {
          int id_remate = int.Parse(hid_id_remate.Text);
          cmbRemates.SetValueAndFireSelect(id_remate);
        }
      }
      catch (Exception ex)
      {
        Mensajes.Error(ErrorText.ERROR_CARGAR_REMATES_AGRUPADOS, "wf_agrupador_remates_adm.CmbRemates_OnReadData", ex);
      }
    }
    protected void StrRemates_OnReadData(object sender, StoreReadDataEventArgs e)
    {
      try
      {
        int start = e.Start;
        int limit = NumInt.Init(e.Parameters.GetParameter("limit").Value);
        limit = limit == 0 ? e.Limit : limit;
        int page = (start / limit) + 1;

        co_re_remates_no Nomina = new co_re_remates_no();

        Nomina.Pagina = page;
        Nomina.RegistrosPorPaginas = e.Limit;
        Nomina.ColumnaOrden = e.Sort[0].Property;
        Nomina.OrdenColumna = (FwpServerControls.FwpDataGridDataBound.Orden)Enum.Parse(typeof(FwpServerControls.FwpDataGridDataBound.Orden), e.Sort[0].Direction.ToString(), true);
        
 

         IList<object> temp = new List<object>();



        Nomina<co_re_remates_no> data = new bf_re_remates().GetNominaAgrupados(Nomina);

        foreach (co_re_remates_no n in data.DataSource)
        {

          temp.Add(
              new
              {
                rem_nombre = n.rem_nombre,
                rem_fechaagrupa = n.rem_fechaagrupa.Fecha,
                us_consuser = n.us_consuser,
                id_remate = n.id_remate,
                id_remate_base = n.id_remate_base.ToString(),
                rem_lugarRemate = n.rem_lugarRemate,
                rem_fecha = n.rem_fecha.Fecha,
                rem_nombreAgrupado = n.rem_nombreAgrupado + " - " + n.rem_fecha.Fecha.ToShortDateString()
              });
        }

        strRemates.DataSource = temp;
        strRemates.PageSize = limit;
        PageProxy pageProxy = strRemates.Proxy[0] as PageProxy;
        if (pageProxy != null) pageProxy.Total = data.Registros;
        strRemates.DataBind();
      }
      catch(Exception ex)
      {
        Mensajes.Error(ErrorText.ERROR_CARGAR_REMATES_AGRUPADOS, "wf_agrupador_remates.StrRemates_OnReadData" ,ex);
      }
    }
    private void CargarComboRemates()
    {
      int id_remate = hid_id_remate.Text.ValidaEntero("id_remate");
      co_re_remates remate = new bf_re_remates().GetData(id_remate);
      IList<co_re_remates> listRemates = new bf_re_remates().GetData(new co_re_remates ());
      ObtenerRematesAdicionales(ref listRemates,remate);


      listRemates.OrderBy(x => x.rem_nombre);
      if (listRemates.Any())
      {
        strCmbRemates.DataSource = listRemates;
        strCmbRemates.DataBind();
      }
    }
    private void CargarReporte(string id)
    {
      try
      {
        int id_remate = Int32.TryParse(id, out id_remate) ? id_remate : 0;
        string titulo = "ACTA GENERAL DE ";
        if (id_remate != 0)
        {
          co_re_remates remate = new bf_re_remates().GetData(id_remate);
          co_re_tiposremates tipo = new bf_re_tiposremates().GetData(remate.id_tiporemateLicitacion);
          titulo += tipo.tip_descripcion.ToUpper() + " - REMATE " + remate.rem_fecha.Fecha.Day + " DE " +
                    remate.rem_fecha.Fecha.ToString("MMMM").ToUpper() + " DE " +
                    remate.rem_fecha.Fecha.Year;

          DataSet ds = new bf_re_remates().GetActaMartilleroReport(id_remate);
          if (ds.Tables.Count != 0)
          {
            ReportDataSource data = new ReportDataSource("DsActaMartillero", ds.Tables[0]);
            ReportParameter parameter = new ReportParameter("titulo", titulo);

            rptActaMartillero.LocalReport.DataSources.Clear();
            rptActaMartillero.LocalReport.DataSources.Add(data);
            rptActaMartillero.LocalReport.SetParameters(parameter);
            rptActaMartillero.LocalReport.Refresh();
            rptActaMartillero.DataBind();
          }
          else
          {
            Mensajes.Error("No se encontraron Registros.");
          }
        }
        else
        {
          Mensajes.Error("No se encuentra el ID para este Remate");
        }

      }
      catch (Exception ex)
      {
        Mensajes.Error(ex.Message);

      }
    }
 protected override void Page_Load(object sender, EventArgs e)
 {
   try
   {
     base.Page_Load(sender, e);
     if (!IsPostBack && !X.IsAjaxRequest)
     {
       hid_idRemate.Text = NumInt.Init(Request.QueryString["id_remate"]).ToString();
       co_re_remates remate = new bf_re_remates().GetData(hid_idRemate.Text.ValidaEntero("id_remate"));
       hid_idFamilia.Text = remate.id_familia.ToString();
       hid_esPresencial.Text = (remate.id_tiporemate.id == Constantes.PRESENCIAL).ToString();
       co_re_familias familia = new bf_re_familias().GetData(remate.id_familia);
       hid_esPropiedad.Text = EstadosRegistros.ConvertirABool(familia.fa_flg_espropiedad).ToString();
       hidden_tam_imagen.Text = Constantes.TAMANO_IMAGEN;
     }
   }
   catch (Exception ex)
   {
     Mensajes.Error(ex.Message + "Page_Load");
   }
 }
    private void CargarReporte(int id_remate)
    {
      try
      {
        string titulo = "CATALOGO ";
        if (id_remate != 0)
        {
          co_re_remates remate = new bf_re_remates().GetData(id_remate);
          co_re_tiposremates tipo = new bf_re_tiposremates().GetData(remate.id_tiporemateLicitacion);
          titulo += tipo.tip_descripcion.ToUpper() + " - REMATE " + remate.rem_fecha.Fecha.Day + " DE " +
                    remate.rem_fecha.Fecha.ToString("MMMM").ToUpper() + " DE " +
                    remate.rem_fecha.Fecha.Year;

          DataSet ds = new bf_re_remates().GetActaRemateAgrupadosReport(id_remate);
          if (ds.Tables.Count != 0)
          {
            ReportDataSource data = new ReportDataSource("ds_catalogo_agrupados", ds.Tables[0]);
            ReportParameter parameter = new ReportParameter("titulo", titulo);

            rptCatalogoAgrupados.LocalReport.DataSources.Clear();
            rptCatalogoAgrupados.LocalReport.DataSources.Add(data);
            rptCatalogoAgrupados.LocalReport.SetParameters(parameter);
            rptCatalogoAgrupados.LocalReport.Refresh();
            rptCatalogoAgrupados.DataBind();
          }
          else
          {
            Mensajes.Error("No se encontraron Registros.");
          }
        }
        else
        {
          Mensajes.Error("No se encuentra el ID para este remate");
        }
      }
      catch (Exception ex)
      {
        Mensajes.Error(ex.Message);
      }
    }
    private void CargarReporte(int id_remate)
    {
      try
      {
        if (id_remate > 0)
        {
          DataSet ds = new bf_re_remates().GetCatalogoRemateReport(id_remate);
          if (ds.Tables.Count != 0)
          {
            ReportDataSource data = new ReportDataSource("ds_catalogo_remate", ds.Tables[0]);
            ReportDataSource datasource = data;
            rpt_catalogo_remate.LocalReport.EnableExternalImages = true;
            rpt_catalogo_remate.ProcessingMode = ProcessingMode.Local;
            string imagePath = "file://" + ds.Tables[0].Rows[0].ItemArray[6].ToString();
            //string imagePath = "file://c:\mysite\images\myimage.bmp";
            ReportParameter parameter = new ReportParameter("imagen", imagePath);

            rpt_catalogo_remate.LocalReport.DataSources.Clear();
            rpt_catalogo_remate.LocalReport.DataSources.Add(datasource);
            rpt_catalogo_remate.LocalReport.SetParameters(parameter);
            rpt_catalogo_remate.LocalReport.Refresh();
          }
          else
          {
            Mensajes.Error("No se Encontraron Registros");
          }
        }
        else
        {
          Mensajes.Error("No se encuentra el ID para este Remate");
        }
      }
      catch (Exception ex)
      {
        Mensajes.Error(ex.Message);
      }
    }
    protected void btnBuscar_Click(object sender, DirectEventArgs e)
    {
      try
      {
        string mensaje = string.Empty;
        int id_remate = hid_idRemate.Text.ValidaEntero("id_remate");
        co_re_remates remate = new bf_re_remates().GetData(id_remate);
        if (!string.IsNullOrEmpty(txtPatente.Text.Trim()))
        {
          ResultadoSapData res = BF_Patente.ObtenerPatente(txtPatente.Text.ToUpper());

          if (res.isValid)
          {
            txtNombre.Text = res.data.descripcion.ToUpper() + ", " + res.data.marca.ToUpper() + ", "
              + res.data.anio.ToString().ToUpper() + ", " + res.data.modelo.ToUpper();
            txtNroLote.Text = res.data.lote;
            txtCantidad.Text = res.data.cantidad.ToString();
            //txtDescripcion.Text = res.data.descripcion;
            txtMinimo.Text = res.data.minimo.ToString("N0");
            txtUnidadMedida.Text = res.data.unidadmedida;
            txtComision.Text = res.data.comision.Replace(".",",");
            txtIncremento1.Text = res.data.incremento.ToString("N0");
            cmbTipoDireccion.SetValueAndFireSelect("DIR");
            txtDireccion.Text = res.data.direccion;
            chkIva.Value = res.data.iva.ToUpper().Equals("SI");
            int idMandante = BuscarMandante(res.data.mandante, ref mensaje);
            int idMoneda = BuscarMoneda(res.data.moneda, ref mensaje);
            int idComuna = BuscarComuna(res.data.comuna, ref mensaje);
            int idCategoria = BuscarCategoria(res.data.categoria, remate, ref mensaje);
            int idSubcategoria = 0;
            if (idCategoria != 0)
            {
              res.data.subcategoria = HomologarSubcategoria(res.data.subcategoria);
              idSubcategoria = BuscarSubcategoria(res.data.subcategoria, idCategoria, ref mensaje);
              cmbCategoria.SetValueAndFireSelect(idCategoria);
              if (idSubcategoria != 0) cmbSubCategoria.SetValueAndFireSelect(idSubcategoria);
            }
            if (idMandante != 0) cmbMandantes.SetValueAndFireSelect(idMandante);
            if (idMoneda != 0) cmbMoneda.SetValueAndFireSelect(idMoneda);
            if (idComuna != 0)
            {
              int idRegion = BuscarRegion(idComuna, ref mensaje);
              cmbRegion.SetValueAndFireSelect(idRegion);
              cmbComuna.SetValueAndFireSelect(idComuna);
            }

            if (!string.IsNullOrEmpty(mensaje))
            {
              Mensajes.Error(mensaje);
            }

            winPatente.Hide();
          }
          else
          {
            Mensajes.Error(res.mensaje);
          }
        }
        else
        {
          Mensajes.Error("Se debe Ingresar una Patente");
        }
      }
      catch (Exception ex)
      {
        Mensajes.Error("Se Produjo un Error al tratar de Buscar la Patente Ingresada <br> Metodo btnBuscar_Click <br> Error:" + ex.Message);
      }
    }
 private void CargaCombos()
 {
   int id_loteo = NumInt.Init(Request.QueryString["id_loteo"]);
   int id_remate = hid_idRemate.Text.ValidaEntero("id_remate");
   co_re_remates remate = new bf_re_remates().GetData(id_remate);
   Combos.CargaMoneda(strCmbMoneda);
   cmbMoneda.SeleccionarOpcion(Constantes.MONEDA_PESOS.ToString());
   Combos.CargaMoneda(strCmbMonedaGarantia);
   cmbMonedaGarantia.SeleccionarOpcion(Constantes.MONEDA_PESOS.ToString());
   Combos.CargarLoteosEstado(strCmbEstado);
   Combos.CargarMandantes(strCmbMandantes);
   Combos.CargaCanales(strCmbCanales);
   cmbCanales.SetValueAndFireSelect(Constantes.CANAL_WEB.ToString());
   Combos.CargarRegiones(strCmbRegion);
   Combos.CargaFamilias(strCmbFamilia, remate.id_rematetipo.id);
   cmbFamilias.SetValueAndFireSelect(remate.id_familia);
   cmbTipoDireccion.SetValueAndFireSelect("DIR");
   Combos.CargarUnidades(strCmbUniMedSupConstruida);
   cmbUniMedSupConstruida.SeleccionarOpcion(Constantes.UNIDAD_DEFECTO.ToString());
   Combos.CargarUnidades(strCmbUniMedSupSitio);
   cmbUniMedSupSitio.SeleccionarOpcion(Constantes.UNIDAD_DEFECTO.ToString());
   GetContactos();
   CargarAtributos(id_loteo);
   CargarAtributosFamilia(Constantes.ATRIBUTOS_TABLA_FAMILIA, id_loteo, remate.id_familia);
 }
    private void ConfigurarFormulario()
    {
      try
      {
        int id_remate = hid_idRemate.Text.ValidaEntero("id_remate");
        co_re_remates remate = new bf_re_remates().GetData(id_remate);
        if (remate.id_rematetipo.id == Constantes.REMATETIPO_REMATE)
        {
          txtCodigo.AllowBlank = true;
          txtCodigo.Hidden = true;

          fieldExhibicion.Hidden = true;
          txtLugarExhibicion.AllowBlank = true;
          txtExhibicion.AllowBlank = true;

          fieldContacto.Hidden = true;
          if (remate.id_familia == Constantes.FAMILIA_BIENESMUEBLES)
          {
            fieldSuperficies.Hidden = true;
            txtSuperficieConstruida.AllowBlank = true;
            txtSuperficieSitio.AllowBlank = true;
            cmbUniMedSupConstruida.AllowBlank = true;
            cmbUniMedSupSitio.AllowBlank = true;
            toolPatente.Hidden = false;
          }
          if (remate.id_familia == Constantes.FAMILIA_PROPIEDADES)
          {
            txtCantidad.AllowBlank = true;
            txtCantidad.Hidden = true;
            txtUnidadMedida.AllowBlank = true;
            txtUnidadMedida.Hidden = true;
          }
          if (remate.id_tiporemate.id == Constantes.PRESENCIAL)
          {
            txtIncremento1.AllowBlank = true;
            txtIncremento1.Hidden = true;
            txtIncremento2.AllowBlank = true;
            txtIncremento2.Hidden = true;
          }
        }
        if (remate.id_rematetipo.id == Constantes.REMATETIPO_VENTA_DIRECTA)
        {
          txtCodigo.AllowBlank = true;
          txtCodigo.Hidden = true;
          txtCantidad.AllowBlank = true;
          txtCantidad.Hidden = true;
          txtUnidadMedida.AllowBlank = true;
          txtUnidadMedida.Hidden = true;

          txtMinimo.FieldLabel = "Venta";

          txtIncremento1.AllowBlank = true;
          txtIncremento1.Hidden = true;
          txtIncremento2.AllowBlank = true;
          txtIncremento2.Hidden = true;
          cmbMandantes.AllowBlank = true;
          cmbMandantes.Hidden = true;
          if (remate.id_familia == Constantes.FAMILIA_BIENESMUEBLES_VENTADIRECTA)
          {
            fieldSuperficies.Hidden = true;
            txtSuperficieConstruida.AllowBlank = true;
            txtSuperficieSitio.AllowBlank = true;
            cmbUniMedSupConstruida.AllowBlank = true;
            cmbUniMedSupSitio.AllowBlank = true;
            txtGarantia.AllowBlank = true;
            txtGarantia.Hidden = true;
            cmbMonedaGarantia.AllowBlank = true;
            cmbMonedaGarantia.Hidden = true;
          }
          if (remate.id_familia == Constantes.FAMILIA_PROPIEDADES_VENTADIRECTA)
          {
            fieldExhibicion.Hidden = true;
            txtLugarExhibicion.AllowBlank = true;
            txtExhibicion.AllowBlank = true;
          }
        }
        if (remate.id_rematetipo.id == Constantes.REMATETIPO_ARRIENDO)
        {
          txtNroLote.AllowBlank = true;
          txtNroLote.Hidden = true;

          txtCantidad.AllowBlank = true;
          txtCantidad.Hidden = true;
          txtDescripcion.AllowBlank = true;
          txtDescripcion.Hidden = true;

          txtMinimo.FieldLabel = "Valor Arriendo";
          chkIva.Hidden = true;
          txtUnidadMedida.AllowBlank = true;
          txtUnidadMedida.Hidden = true;
          txtComision.AllowBlank = true;
          txtComision.Hidden = true;

          //incrementos y garantia
          txtGarantia.AllowBlank = true;
          txtGarantia.Hidden = true;
          cmbMonedaGarantia.AllowBlank = true;
          cmbMonedaGarantia.Hidden = true;
          txtIncremento1.AllowBlank = true;
          txtIncremento1.Hidden = true;
          txtIncremento2.AllowBlank = true;
          txtIncremento2.Hidden = true;

          //exhibicion
          fieldExhibicion.Hidden = true;
          txtLugarExhibicion.AllowBlank = true;
          txtExhibicion.AllowBlank = true;

          txtObservacion.Hidden = true;

          cmbMandantes.AllowBlank = true;
          cmbMandantes.Hidden = true;
        }
        win_mapa.Hide();
      }
      catch (Exception ex)
      {
        Mensajes.Error(ErrorText.ERROR_CONFIGURAR_FORMULARIO_LOTE + "<br />" + ex.Message);
      }
    }
 private string ObtenerConexion(int id_remate) {
   co_re_remates remate = new bf_re_remates().GetData(id_remate);
   string conexion = string.Empty;
   if (remate.id_familia == Constantes.FAMILIA_PROPIEDADES)
   {
     conexion = Constantes.CONEXION_PROPIEDADES;
   }
   else
   {
     conexion = Constantes.CONEXION_ONLINE;
   }
   return conexion;
 }
 protected void btnBorrar_click(object sender, DirectEventArgs e)
 {
   try
   {
     Boolean remates = new bf_re_remates().DeleteAllRemate(int.Parse(hidden_id_remate.Text));
     if (remates)
     {
       Mensajes.Show("Exito", ErrorText.REGISTRO_BORRADO, "CloseIframe();", MessageBox.Icon.INFO);
     }
     else
     {
       Mensajes.Error(ErrorText.ERROR_ELIMINAR_REMATE);
     }
   }
   catch (Exception)
   {
     Mensajes.Error(ErrorText.ERROR_ELIMINAR_REMATE);
   }
 }
 private string ObtenerUrlGarantia(string id)
 {
     try
     {
         int id_remate = id.ValidaEntero("id_remate");
         co_re_remates remate = new bf_re_remates().GetData(id_remate);
         if (remate != null && remate.id != 0)
         {
             if (remate.id_familia == Constantes.FAMILIA_BIENESMUEBLES)
             {
                 return "wf_pa_rl_garantia_ingreso.aspx?id_remate=" + id;
             }
             if (remate.id_familia == Constantes.FAMILIA_PROPIEDADES)
             {
                 return "wf_agrupados_garantias.aspx?id_remate=" + id;
             }
         }
     }
     catch (Exception ex)
     {
         Mensajes.Error(ex.Message);
     }
     return "";
 }
        public void Open_win_mantenedor(object sender, DirectEventArgs e)
        {
            string tipo = e.ExtraParams["command"];
            string id = e.ExtraParams["id"];
            string url = string.Empty;
            string nom_remate = e.ExtraParams["nombre"];
            string id_familia = e.ExtraParams["id_familia"];
            Icon icono = Icon.None;
            string title = string.Empty;


            switch (tipo)
            {
                case "Agregar":
                    url = "wf_re_remates_adm.aspx?id_rematetipo=1&id_remate=0&op=in";
                    icono = Icon.ApplicationFormAdd;
                    title = "Agregar Remate";
                    break;
                case "CatVehiculos":
                    //url = ObtenerUrlCatalogo(id);
                    //url = "../Reportes/Catalogo/wf_catalogo_remate.aspx?id_remate=" + id;
                    url= Constantes.URL_PRINCIPAL_ADMIN + "Catalogo/wf_catalogo_remate.aspx?id_remate=" + id;
                    icono = Icon.Report;
                    title = "Catálogo del Remate \"" + nom_remate + "\"";
                    break;
                case "CatNoVehiculos":
                    //url = ObtenerUrlCatalogo(id);
                    //url = "../Reportes/Catalogo/wf_catalogo_remate.aspx?id_remate=" + id;
                    url= Constantes.URL_PRINCIPAL_ADMIN + "Catalogo/wf_catalogo_remate_no_vehiculos.aspx?id_remate=" + id;
                    icono = Icon.Report;
                    title = "Catálogo del Remate \"" + nom_remate + "\"";
                    break;
                case "Acta":
                    url = ObtenerUrlActa(id);
                    //url = "../Reportes/Acta/wf_acta_remate.aspx?id_remate=" + id;
                    icono = Icon.Book;
                    title = "Acta del Remate \"" + nom_remate + "\"";
                    break;
                case "Vista":
                    co_re_remates remate = new bf_re_remates().GetData(id.ValidaEntero("id_remate"));
                    url = FamiliaPreview.ObtenerUrlVistaPreviaRemate(remate);
                    icono = Icon.PageMagnify;
                    title = "Vista Previa del Remate \"" + nom_remate + "\"";
                    break;
                case "Imagen":
                    url = "../AdministradorCargaImagenes/wf_carga_imagenes.aspx?id_origen=" + id + "&id_tabla=" + Constantes.TABLA_REMATES + "&id_familia=" + id_familia + "&id_carpeta=" + id + "";
                    icono = Icon.ApplicationViewTile;
                    title = "Imágenes del Remate \"" + nom_remate + "\"";
                    break;
                case "Lotes":
                    url = "Administracion/wf_pa_loteos_no.aspx?id_remate=" + id;
                    icono = Icon.ApplicationViewColumns;
                    title = "Lotes del Remate " + nom_remate;
                    break;
                case "Modificar":
                    url = "wf_re_remates_adm.aspx?id_rematetipo=1&id_remate=" + id + "&op=mo";
                    icono = Icon.ApplicationFormEdit;
                    title = "Modificar Remate \"" + nom_remate + "\"";
                    break;
                case "Eliminar":
                    url = "wf_re_remates_adm.aspx?id_rematetipo=1&id_remate=" + id + "&op=el";
                    icono = Icon.ApplicationFormDelete;
                    title = "Eliminar Remate \"" + nom_remate + "\"";
                    break;
                case "Garantia":
                    url = ObtenerUrlGarantia(id);
                    icono = Icon.ApplicationDouble;
                    title = "Garantías del Remate \"" + nom_remate + "\"";
                    break;
            }
            if (tipo == "Lotes")
            {
                Notificaciones.Show("Mensaje", "Abriendo Lotes...", "window.top.OpenWindow('" + title + "','" + url + "','lotes" + id + "','#Application')", Icon.Table, 1000);
            }
            else
            {
                this.win_mantenedor.Html = url.GetIFrameWindow();
                this.win_mantenedor.Title = title;
                this.win_mantenedor.Icon = icono;
                this.win_mantenedor.Show();
            }
        }
    private void CargarDatos(int id_remate)
    {
      try
      {
        co_re_remates remate = new bf_re_remates().GetData(id_remate);
        if (remate.id_tiporemate.id == Constantes.PRESENCIAL || Constantes.PERFIL_ADMINISTRADOR_REMATES_PLG != FWPConfiguration.get_Perfil(Session.SessionID))
        {
          btnCargaRemateLinea.Hide();
        }

        txtNombre.Text = remate.rem_nombre;
        txtLugarRemate.Text = remate.rem_lugarRemate;
        cmbRemateWeb.SetValueAndFireSelect(remate.id_tiporemate.id);
        cmbTipo.SetValueAndFireSelect(remate.id_tiporemateLicitacion);
        cmbFamilias.SetValueAndFireSelect(remate.id_familia);
        cmbEstadoRemate.SetValueAndFireSelect(remate.id_remateEstadoWeb.id);
        ConfiguraFormularioFamilia(remate.id_familia);
        txtFechaRemate.Text = remate.rem_fecha.Fecha.ToString();
        txtHoraRemate.Text = remate.rem_hora.Fecha.ToShortTimeString();
        txtLugarExhibicion.Text = remate.rem_exhibicion_texto;
        txtDescripcion.Text = remate.rem_descripcion;
        CargaResponsables(id_remate);
        CargaContactos(id_remate);
        CargaCanales(id_remate);
      }
      catch (Exception)
      {
        Mensajes.Error(ErrorText.ERROR_CARGAR_REMATE);
      }
    }
    private void Asocia(IEnumerable<Remate> list)
    {
      try
      {
        IList<co_rl_loteos> listLotesPLG = new List<co_rl_loteos>();
        IList<co_re_remates> listRemates = new List<co_re_remates>();
        int id_remate_base = 0;
        if (hid_id_remate.Text == "")
        {
          id_remate_base = Int32.Parse(cmbRemates.SelectedItem.Value);
        }
        else
        {
          id_remate_base = Int32.Parse(hid_id_remate.Text);
        }
        foreach (co_re_remates reRemates in list.Select(remate => new bf_re_remates().GetData(remate.id_remate)))
        {
          co_re_remates remate = new bf_re_remates().GetData(id_remate_base);
          if (!remate.rem_fecha.Fecha.ToShortDateString().Equals(reRemates.rem_fecha.Fecha.ToShortDateString()))
          {
            RematesDisponibles(id_remate_base);
            RematesAgrupados(id_remate_base);
            throw new Exception("Se produjo un error al tratar de agrupar el remate, para agrupar el remate deben tener la misma fecha");
          }
          reRemates.id_remate_base = id_remate_base;
          reRemates.id_usuario_agrupa = FWPConfiguration.get_ID_User(Session.SessionID);
          reRemates.rem_fechaagrupa.Fecha = DateTime.Now;
          listRemates.Add(reRemates);
          var lotes = new bf_rl_loteos().GetData(new co_rl_loteos { id_remate = { id = reRemates.id_remate } });
          foreach (co_rl_loteos lote in lotes)
          {
            lote.id_remate_origen = reRemates.id_remate;
            new bf_rl_loteos().Save(lote);
            lote.id_remate.id = id_remate_base;
            listLotesPLG.Add(lote);
          }
        }
        new bf_re_remates().Save(listRemates);


        ConexionPlgOnline plg = null;
        foreach (co_re_remates remate in listRemates)
        {

          string conexion = string.Empty;
          if (remate.id_familia == Constantes.FAMILIA_PROPIEDADES)
          {
            conexion = Constantes.CONEXION_PROPIEDADES;
          }
          else
          {
            conexion = Constantes.CONEXION_ONLINE;
          }
          plg = new ConexionPlgOnline(conexion);
          plg.GrabaRemate(remate);
        }
        plg.GrabaLotes(listLotesPLG);
        Mensajes.Show("Mensaje", ErrorText.REMATE_AGRUPADO_EXITOSAMENTE, Mensajes.Icon.INFO);
      }
      catch (Exception ex)
      {
        throw new Exception("Asocia: " + ex.Message);
      }
    }
 private void RematesAgrupados(int id_remate)
 {
   IList<object> lista = new List<object>();
   IList<co_re_remates> listRemates = new bf_re_remates().GetData(new co_re_remates { id_remate_base = id_remate });
   foreach (co_re_remates re in listRemates)
   {
     lista.Add(new
     {
       id_remate = re.id_remate,
       rem_nombre = re.rem_nombre,
       rem_fecha = re.rem_fecha.Fecha
     });
   }
   strRematesAgrupados.DataSource = lista;
   strRematesAgrupados.DataBind();
 }
 private void RematesDisponibles(int id_remate)
 {
   IList<object> lista = new List<object>();
   IList<co_re_remates> listRemates = new bf_re_remates().
     GetDataAgrupadosDisponibles(new co_re_remates { id_remateEstadoWeb = { id = Constantes.ESTADO_REMATE_PUBLICADO }, id_rematetipo = { id = ID_REMATETIPO }, id_familia = Constantes.FAMILIA_PROPIEDADES });
   foreach (co_re_remates re in listRemates)
   {
     lista.Add(new
     {
       id_remate = re.id_remate,
       rem_nombre = re.rem_nombre,
       rem_fecha = re.rem_fecha.Fecha
     });
   }
   strRematesDisponibles.DataSource = lista;
   strRematesDisponibles.DataBind();
 }
    private void InformarPersona()
    {
      try
      {
        int id_remate = Convert.ToInt32(hidId_Remate.Text);

        const string Formato = @"<div style='width:600px;'>
            <p>Estimado <b>{0}</b></p>
            <p>Le comunicamos  que su garantía para el remate <b>{1}</b>, a realizarse el día <b>{2}</b> han sido aceptada.
            <br />Tenga presente que su nombre de usuario y clave soló están habilitados el mismo día del remate.</p>

            <p>Presione <a href='{3}'> aquí</a> para dirigirse al remate</p>
            <br />
            <p>Atte.<br />{5}</p>
            <p><img src='{4}'/></p>
            </div>";
        List<MailAddress> destinatarios = new List<MailAddress>();
        destinatarios.Add(new MailAddress(txtEmail.Text, txtNombre.Text+" "+txtApePaterno.Text));

        //obtengo el remate para rescatar el nombre
        IList<co_re_remates> remate =
          new bf_re_remates().GetData(new co_re_remates { id_remate = id_remate });


        if (remate != null && remate.Any())
        {
          //string fecha =  Convert.ToString().Remove(10, remate.First().rem_fecha.Fecha.tos.Length-10)
          string cuerpo = string.Format(Formato,
            txtNombre.Text + ' ' + txtApePaterno.Text,
            remate.First().rem_nombre,
            remate.First().rem_fecha.Fecha.ToShortDateString(),
            Constantes.URL_REMATE_ONLINE_ACREDITACION_PROPIEDADES + "&id_remate=" + hidId_Remate.Text,
            Constantes.LOGO_TATTERSALL,
            Constantes.FIRMA_INSCRIPCION_REMATE);

          Mailer.Enviar("Remates", cuerpo, destinatarios);
        }
      }
      catch (Exception ex)
      {
        X.MessageBox.Alert("Error", ex.Message).Show();
      }
    }
 private string ObtenerConexion()
 {
   try
   {
     int _id_remate = hidId_Remate.Text.ValidaEntero("id_remate");
     co_re_remates remate = new bf_re_remates().GetData(_id_remate);
     string conexion = string.Empty;
     if (remate.id_familia == Constantes.FAMILIA_PROPIEDADES)
     {
       conexion = Constantes.CONEXION_PROPIEDADES;
     }
     else
     {
       conexion = Constantes.CONEXION_ONLINE;
     }
     return conexion;
   }
   catch (Exception ex)
   {
     throw new Exception(ErrorText.ERROR_OBTENER_STRING_CONEXION + "Nomina Garantias <br>" + ex.Message);
   }
 }
    /// <summary>
    /// Metodo que Notifica al Usuario Movil acerca del Lote de acuerdo a sus preferencias
    /// </summary>
    /// <param name="idLote"></param>
    /// <param name="idRemate"></param>
    public static string NotificarTest(int idLote, int idRemate)
    {
      string mensaje = string.Empty;
      try
      {
        getTransaccion();
        co_rl_loteos lote = new bf_rl_loteos().GetData(idLote);
        co_re_remates remate = new bf_re_remates().GetData(idRemate);
        //valido que el remate no sea nulo
        if (remate != null)
        {
          //valido q el remate esta publicado
          if (remate.id_remateEstadoWeb.id == PUBLICADO)
          {
            //valido que el lote no sea nulo
            if (lote != null)
            {
              //valido q este marcado como activo
              if (lote.id_loteoestado.id == LOTE_ACTIVO)
              {
                //una vez validado los estados valido que este marcado como movil
                co_rl_loteoscanales canal = new bf_rl_loteoscanales().GetData(new co_rl_loteoscanales { id_loteo = { id = lote.id_loteo }, id_canal = { id = CANAL_MOVIL } }).FirstOrDefault();
                if (canal != null)
                {
                  getTransaccion();
                  //realizo la instancia del wsdl para la notificacion.
                  WsNotificacion notificacion = new WsNotificacionClient();

                  //obtengo todos los lotes del remate con la opcion de canal movil
                  var mvSubcategorias =
                    new bf_mv_mosubcategorias_subcategorias().GetData(new co_mv_mosubcategorias_subcategorias
                    {
                      id_subcategoria = lote.id_subcategoria
                    });
                  string subcategoriasMovil = mvSubcategorias.Aggregate(string.Empty,
                    (current, sb) => current + sb.id_mosubcategoria.id + ",");
                  if (subcategoriasMovil.Length > 0)
                  {
                    subcategoriasMovil = subcategoriasMovil.Substring(0, (subcategoriasMovil.Length - 1));
                  }else
                  {
                    subcategoriasMovil = @"0";
                  }

                  var usuariosWeb = new bf_ca_usuariosweb().getUsuariosSubcategoriasMovil(subcategoriasMovil);
                  //verifico si hay usuario a los que notificar de lo contrario no hago nada
                  if (usuariosWeb.Any())
                  {
                    Publicacion publicacion = new Publicacion
                    {
                      esRemate = EsRemate(remate),
                      id = lote.id_loteo,
                      titulo = lote.lo_titulo
                    };
                    IList<Usuario> usuarios = new List<Usuario>();
                    string nombreCompleto = string.Empty;
                    foreach (var usu in usuariosWeb)
                    {
                      int uuid = 1749;
                      nombreCompleto = usu.pe_nombrecompleto;
                      usuarios.Add(new Usuario { uuid = uuid.ToString(), nombre = nombreCompleto });
                    }
                    publicacion.Usuarios = usuarios.ToArray();

                    NotificarRequest notificarRequest = new NotificarRequest
                    {
                      DatosTransaccion = _transaccion,
                      Publicacion = publicacion
                    };

                    NotificarResponse response = notificacion.Notificar(notificarRequest);
                    //guardo la respuesta realizada por el WebService
                    GuardarResponseMovil(response, lote.id_loteo, remate.id_remate, publicacion);

                    mensaje = "Lote Notificado Exitosamente.";
                  }else
                  {
                    mensaje = "No hay usuarios al cual Notificar.";
                  }
                }
                else
                {
                  mensaje = "Debe Seleccionar Canal Movil para poder notificar";
                }
              }
              else
              {
                mensaje = "Lote debe estar con estado ACTIVO para poder notificar";
              }
            }
            else
            {
              mensaje = "Lote Nulo";
            }
          }
          else
          {
            mensaje = "Remate debe estar PUBLICADO para poder notificar.";
          }
        }
        else
        {
          mensaje = "Remate Nulo";
        }
      }
      catch (Exception ex)
      {
        return "Error al notificar <br>" + ex.Message;
      }
      return mensaje;
    }
        private void CrearExcel(ref IList<object> lista, DirectEventArgs e, bool tienelimite)
        {
            if (lista == null) throw new ArgumentNullException("lista");
            JObject sortinfo = (JObject)JsonConvert.DeserializeObject(e.ExtraParams["SortInfo"]);

            co_re_remates_no Nomina = new co_re_remates_no();
            lista = new List<object>();

            Nomina.Pagina = 1;
            Nomina.RegistrosPorPaginas = 1;
            Nomina.ColumnaOrden = sortinfo["field"].ToString();
            Nomina.OrdenColumna = FwpServerControls.FwpDataGridDataBound.Orden.DESC;
            AgregarFiltros(ref Nomina);

            Nomina<co_re_remates_no> data = new bf_re_remates().GetNomina(Nomina);

            Nomina.Pagina = 1;
            if (tienelimite)
            {
                Nomina.RegistrosPorPaginas = data.Registros < 65000 ? data.Registros : (int)(65000);
            }
            else
            {
                //idea principal de esto es enviar la todos los registros, pero por temas de rendimiento se limito.
                Nomina.RegistrosPorPaginas = data.Registros < 100000 ? data.Registros : (int)(100000);
            }

            //recuepra la totalidad de datos permitidos
            data = new bf_re_remates().GetNomina(Nomina);

            foreach (co_re_remates_no n in data.DataSource)
            {
                lista.Add(
                    new
                    {
                        rem_nombre = n.rem_nombre,
                        fa_familia = n.fa_familia,
                        re_rematetipo = n.rt_rematetipo,
                        rw_remateEstadoWeb = n.rw_remateEstadoWeb,
                        rem_fecha = n.rem_fecha.Fecha.ToShortDateString(),
                        rem_lugarRemate = n.rem_lugarRemate,
                        visitas = n.cont_cuenta_visitas,
                        descargabases = n.cont_cuenta_bases,
                    });
            }


        }
        public string EliminarImagenes(int? id_imagen, string url_imagen, string id_carpeta, int id_tabla)
        {
            JObject response = new JObject();
            if (id_imagen != null && url_imagen != null && id_carpeta != null)
            {
                var im = new bf_tg_imagenes().GetData(new co_tg_imagenes { id_imagen = id_imagen.Value });
                if (im.Any())
                {
                    if (im.First().id_documentotipo.id == Constantes.IMAGEN_IMGLOTE)
                    {
                        if (id_tabla == Constantes.TABLA_REMATES ||
                            id_tabla == Constantes.TABLA_LOTES)
                        {
                            IList<co_re_remates> remate =
                              new bf_re_remates().GetData(new co_re_remates { id_remate = Convert.ToInt32(id_carpeta) });
                            if (remate != null && remate.Any())
                            {
                                if (remate.First().id_tiporemate.id != Constantes.PRESENCIAL)
                                {
                                    var conexion = remate.First().id_familia == Constantes.FAMILIA_PROPIEDADES ? "BD_ONLINE_PROPIEDADES" : "BD_ONLINE";
                                    new ConexionPlgOnline(conexion).EliminaImagen(im.FirstOrDefault(), id_carpeta, url_imagen);
                                }
                            }
                        }
                    }
                }
                string nombreTabla = new bf_tg_tablas().GetData(id_tabla).ta_descripcion.ToLower();
                response.Add(new JProperty("data", new bf_tg_imagenes().EliminaImagen(id_imagen.Value, id_carpeta, url_imagen, nombreTabla)));
            }
            else
            {
                response.Add(new JProperty("data", false));
            }

            return JSON.Serialize(response);
        }
        protected void st_grilla_OnReadData(object sender, StoreReadDataEventArgs e)
        {
            int start = e.Start;
            int limit = NumInt.Init(e.Parameters.GetParameter("limit").Value);
            limit = limit == 0 ? e.Limit : limit;
            int page = (start / limit) + 1;

            co_re_remates_no Nomina = new co_re_remates_no();

            Nomina.Pagina = page;
            Nomina.RegistrosPorPaginas = limit;
            Nomina.ColumnaOrden = e.Sort[0].Property;
            Nomina.OrdenColumna = (FwpServerControls.FwpDataGridDataBound.Orden)Enum.Parse(typeof(FwpServerControls.FwpDataGridDataBound.Orden), e.Sort[0].Direction.ToString(), true);

            IList<object> listRemates = new List<object>();

            AgregarFiltros(ref Nomina);

            BotonesNomina botones = new BotonesNomina(Session);
            Nomina<co_re_remates_no> data = new bf_re_remates().GetNomina(Nomina);

            foreach (co_re_remates_no n in data.DataSource)
            {
                string sUrlSitio = Constantes.URL_PRINCIPAL_ADMIN;
                string sUrlBaseMaquinaria = Constantes.URL_MAQUINARIA_REMATE_SOCIALNETWORK;
                string sUrlBasePropiedades = Constantes.URL_REMATE_PROPIEDADES_SOCIALNETWORK;
                string social = string.Empty;
                if (n.id_familia.Equals(Constantes.FAMILIA_BIENESMUEBLES))
                {
                    social = sUrlSitio + sUrlBaseMaquinaria + n.id_remate;
                }
                else if (n.id_familia.Equals(Constantes.FAMILIA_PROPIEDADES))
                {
                    social = sUrlSitio + sUrlBasePropiedades + n.id_remate;
                }

                listRemates.Add(
                    new
                    {
                        id_remate = n.id_remate,
                        rem_nombre = n.rem_nombre,
                        rem_fecha = n.rem_fecha.Fecha.ToShortDateString(),
                        rem_hora = n.rem_hora.Fecha,
                        id_tiporemate = n.id_tiporemate,
                        rt_rematetipo = n.rt_rematetipo,
                        re_remateEstado = n.re_remateEstado,
                        id_remateEstadoWeb = n.id_remateEstadoWeb,
                        rw_remateEstadoWeb = n.rw_remateEstadoWeb,
                        rem_lugarRemate = n.rem_lugarRemate,
                        rem_nombreIng = n.rem_nombreIng,
                        rem_fechaUTC = n.rem_fechaUTC.Fecha,
                        rem_horaUTC = n.rem_horaUTC.Fecha,
                        rem_horaDesde = n.rem_horaDesde.Fecha,
                        rem_horaHasta = n.rem_horaHasta.Fecha,
                        rem_lugarExhibicion = n.rem_lugarExhibicion,
                        rem_fechaExhibicionDesde = n.rem_fechaExhibicionDesde.Fecha,
                        rem_fechaExhibicionDesde2 = n.rem_fechaExhibicionDesde2.Fecha,
                        rem_fechaExhibicionHasta = n.rem_fechaExhibicionHasta.Fecha,
                        rem_fechaExhibicionHasta2 = n.rem_fechaExhibicionHasta2.Fecha,
                        rem_descripcion = n.rem_descripcion,
                        rem_descripcionIng = n.rem_descripcionIng,
                        rem_garantiaKey = n.rem_garantiaKey,
                        rem_contacto = n.rem_contacto,
                        rem_UrlProcedimiento = n.rem_UrlProcedimiento,
                        rem_destacado = n.rem_destacado,
                        rem_urlFichaRemate = n.rem_urlFichaRemate,
                        id_loteoEnRemate = n.id_loteoEnRemate,
                        id_rematetipo = n.id_rematetipo,
                        re_rematetipo = n.rt_rematetipo,
                        rem_precioMinimo = n.rem_precioMinimo,
                        id_familia = n.id_familia,
                        fa_familia = n.fa_familia,
                        visitas = n.cont_cuenta_visitas,
                        descargabases = n.cont_cuenta_bases,
                        social = social,
                        btnCargarImagenes = botones.btnCargarImagenes,
                        btnActaRemate = botones.btnActaRemate,
                        btnCatalogoRemate = botones.btnCatalogoRemate,
                        btnNominaLotes = botones.btnNominaLotes,
                        btnEliminarRemate = botones.btnEliminarRemate,
                        esPropietario = EsPropietario(n.id_remate) || EsAdministradorRemate()
                    });
            }

            st_grilla.DataSource = listRemates;
            st_grilla.PageSize = limit;
            PageProxy pageProxy = st_grilla.Proxy[0] as PageProxy;
            if (pageProxy != null) pageProxy.Total = data.Registros;
            st_grilla.DataBind();
        }
        public string ActualizarOrden(string ids)
        {
            int id_origen = 0;
            int id_documentoTipo = 0;
            int id_tabla = 0;
            string id_carpeta = null;
            JObject response = new JObject();
            if (ids != null)
            {
                List<co_tg_imagenes> lista_imagenes = new List<co_tg_imagenes>();
                JArray data = (JArray)JSON.Deserialize(ids);
                foreach (var item in data)
                {
                    id_origen = item["id_origen"].Value<int>();
                    id_documentoTipo = item["id_documentotipo"].Value<int>();
                    id_tabla = item["id_tabla"].Value<int>();
                    id_carpeta = item["id_carpeta"].Value<string>();
                    co_tg_imagenes img = new co_tg_imagenes
                    {
                        id_imagen = item["id_imagen"].Value<int>(),
                        id_origen = item["id_origen"].Value<int>(),
                        im_urlImagen = item["im_urlimagen"].Value<string>(),
                        id_documentotipo = {id = item["id_documentotipo"].Value<int>()}
                    };
                    lista_imagenes.Add(img);
                }
                bool orden = new bf_tg_imagenes().CambiaOrdenImagenesNew(lista_imagenes);

                if (orden && id_documentoTipo == Constantes.IMAGEN_IMGLOTE)
                {
                    if (id_tabla == Constantes.TABLA_LOTES || id_tabla == Constantes.TABLA_REMATES)
                    {
                        IList<co_re_remates> remate = new bf_re_remates().GetData(new co_re_remates { id_remate = Convert.ToInt32(id_carpeta) });
                        if (remate != null && remate.Any())
                        {
                            if (remate.First().id_tiporemate.id != Constantes.PRESENCIAL)
                            {
                                var conexion = remate.First().id_familia == Constantes.FAMILIA_PROPIEDADES ? "BD_ONLINE_PROPIEDADES" : "BD_ONLINE";
                                ActualizaPLGOnline(id_origen, id_documentoTipo, conexion);
                            }
                        }
                    }
                }

                response.Add(new JProperty("data", orden));

            }
            else
            {
                response.Add(new JProperty("data", false));
            }

            return JSON.Serialize(response);

        }
 private string ObtenerUrlActa(string id)
 {
     try
     {
         int id_remate = id.ValidaEntero("id_remate");
         co_re_remates remate = new bf_re_remates().GetData(id_remate);
         if (remate != null && remate.id != 0)
         {
             if (remate.id_familia == Constantes.FAMILIA_BIENESMUEBLES)
             {
                 return Constantes.URL_PRINCIPAL_ADMIN + "Acta/wf_acta_remate.aspx?id_remate=" + id;
             }
             if (remate.id_familia == Constantes.FAMILIA_PROPIEDADES)
             {
                 return Constantes.URL_PRINCIPAL_ADMIN + "Acta/wf_acta_remate.aspx?id_remate=" + id;
             }
         }
     }
     catch (Exception ex)
     {
         Mensajes.Error(ex.Message);
     }
     return "";
 }
    protected void btnGuardar_Click(object sender, DirectEventArgs e)
    {
      try
      {
        string atributosParam = e.ExtraParams["atributos"];
        string fechaRemate = e.ExtraParams["fecha_remate"];
        string fechaFinalRemate = e.ExtraParams["fecha_final_remate"];
        IList<JsonAtributos> atributos = JsonConvert.DeserializeObject<List<JsonAtributos>>(atributosParam);
        List<co_tg_personasremate> listaContactos = new List<co_tg_personasremate>();
        if (ObtenerContactos(out listaContactos))
        {
          if (!string.IsNullOrEmpty(fechaRemate))
          {
            if (fechaRemate.Equals("null"))
            {
              fechaRemate = default(DateTime).ToShortDateString(); 
            }
            else
            {
              fechaRemate = fechaRemate.Substring(0, (fechaRemate.Length - 9));
            }
          }
          else
          {
            fechaRemate = default(DateTime).ToShortDateString();
          }

          if (!string.IsNullOrEmpty(fechaFinalRemate))
          {
            if (fechaFinalRemate.Equals("null"))
            {
              fechaFinalRemate = default(DateTime).ToShortDateString();
            }
            else {
              fechaFinalRemate = fechaFinalRemate.Substring(0, (fechaFinalRemate.Length - 9));
            }
          }
          else {
            fechaFinalRemate = default(DateTime).ToShortDateString();
          }


          string mensaje = ErrorText.REGISTRO_INGRESADO;
          co_re_remates remate = new co_re_remates();
          int id_remate = hidden_id_remate.Text.ValidaEntero(hidden_id_remate.FieldLabel);
          if (id_remate != 0)
          {
            remate = new bf_re_remates().GetData(id_remate);
            mensaje = ErrorText.REGISTRO_MODIFICADO;
          }

          remate.rem_nombre = txtNombre.Text.ToUpper();
          remate.rem_lugarRemate = txtLugarRemate.Text.ToUpper();
          //Presencial Mixto o Internet
          remate.id_tiporemate.id = cmbRemateWeb.SelectedItem.Value.ValidaEntero(cmbRemateWeb.FieldLabel);
          //remate o licitacion
          remate.id_tiporemateLicitacion = cmbTipo.SelectedItem.Value.ValidaEntero(cmbTipo.FieldLabel);
          //familias
          remate.id_familia = cmbFamilias.SelectedItem.Value.ValidaEntero(cmbFamilias.FieldLabel);
          //Estado del remate en Linea siempre sera Esperando Inicio
          remate.id_remateEstado.id =
            cmbEstadoRemateLinea.SelectedItem.Value.ValidaEntero(cmbEstadoRemateLinea.FieldLabel);
          //este siempre sera del tipo REMATE
          remate.id_rematetipo.id = id_rematetipo.Text.ValidaEntero(id_rematetipo.FieldLabel);
          //Estado del remate
          remate.id_remateEstadoWeb.id = cmbEstadoRemate.SelectedItem.Value.ValidaEntero(cmbEstadoRemate.FieldLabel);
          remate.rem_descripcionIng = txtFechaRemate.Value.ToString();

          remate.rem_fecha.Fecha = Convert.ToDateTime(fechaRemate);
          remate.rem_hora.Fecha = Convert.ToDateTime(fechaRemate + " " + txtHoraRemate.Value.ToString());
          remate.rem_descripcion = txtDescripcion.Text.ToUpper();
          remate.rem_exhibicion_texto = txtLugarExhibicion.Text.ToUpper();
          remate.id_moneda.id = 1;
          remate.rem_horaHasta.Fecha = Convert.ToDateTime(fechaFinalRemate + " " + txtHoraFinal.Value.ToString());

          List<co_re_canalesremates> listCanales = ObtenerCanales();
          
          List<co_re_responsables> listResponsables = ObtenerResponsables();

          remate = new bf_re_remates().Save(remate, listaContactos, listCanales, listResponsables, FWPConfiguration.get_ID_User(Session.SessionID));

          if (remate.id != 0)
          {
            GrabarAtributosRemate(remate.id_remate,atributos);
            Mensajes.Show("Mensaje", mensaje, "CloseIframe();", MessageBox.Icon.INFO);
          }
        }
        else
        {
          Mensajes.Error("Por favor asegurese de elegir al menos un contacto.");
        }
      }
      catch (Exception ex)
      {
        Mensajes.Error(ex.Message);
      }
    }
 protected void CmbRemates_Select(object sender, DirectEventArgs e)
 {
   try
   {
     int id_remate = Int32.Parse(cmbRemates.SelectedItem.Value);
     cmbRemates.ReadOnly = true;
     if (hid_id_remate.Text == "")
     {
       co_re_remates remate = new bf_re_remates().GetData(id_remate);
       remate.id_remate_base = id_remate;
       remate.id_usuario_agrupa = FWPConfiguration.get_ID_User(Session.SessionID);
       remate.rem_fechaagrupa.Fecha = DateTime.Now;
       string conexion = string.Empty;
       if (remate.id_familia == Constantes.FAMILIA_PROPIEDADES)
       {
         conexion = Constantes.CONEXION_PROPIEDADES;
       }
       else
       {
         conexion = Constantes.CONEXION_ONLINE;
       }
       ConexionPlgOnline plg = new ConexionPlgOnline(conexion);
       plg.GrabaRemate(remate);
       new bf_re_remates().Save(remate);
     }
     RematesDisponibles(id_remate);
     RematesAgrupados(id_remate);
   }
   catch (Exception ex)
   {
     Mensajes.Error(ErrorText.ERROR_SELECCIONAR_REMATE_BASE, "wf_agrupador_remates_adm.CmbRemates_Select", ex);
   }
 }
    protected void str_grilla_OnReadData(object sender, StoreReadDataEventArgs e)
    {
      try
      {
        int start = e.Start;
        int limit = NumInt.Init(e.Parameters.GetParameter("limit").Value);
        limit = limit == 0 ? e.Limit : limit;
        int page = (start / limit) + 1;
        int id_remate = hid_idRemate.Text.ValidaEntero("id_remate");

        co_rl_loteos_no Nomina = new co_rl_loteos_no();
        Nomina.Pagina = page;
        Nomina.RegistrosPorPaginas = e.Limit;
        Nomina.ColumnaOrden = e.Sort[0].Property;
        Nomina.OrdenColumna = (FwpServerControls.FwpDataGridDataBound.Orden)Enum.Parse(typeof(FwpServerControls.FwpDataGridDataBound.Orden), e.Sort[0].Direction.ToString(), true);
        Nomina.id_remate = id_remate;

        IList<object> lista = new List<object>();

        AgregarFiltros(ref Nomina);

        BotonesNominaLotes botones = new BotonesNominaLotes(Session);

        Nomina<co_rl_loteos_no> data = new bf_rl_loteos().GetNomina(Nomina);
        co_re_remates remate = new bf_re_remates().GetData(id_remate);
        if (remate.id_familia != Constantes.FAMILIA_BIENESMUEBLES) {
          MenuCargaMasivaSAP.Hidden = true;
        }
        string sUrlSitio = FamiliaPreview.ObtenerUrlVistaPreviaLotes(remate);

        foreach (co_rl_loteos_no n in data.DataSource)
        {
          //IList<co_tg_contadores> listaContadores = new bf_tg_contadores().GetData(new co_tg_contadores { id_origen = n.id_loteo, id_tipocontador = { id = remate.id_rematetipo.id==Constantes.REMATETIPO_REMATE?Constantes.TIPO_LOTES:remate.id_rematetipo.id} });
          IList<co_tg_contadores> listaContadores = new bf_tg_contadores().GetData(new co_tg_contadores { id_origen = n.id_loteo, id_tipocontador = { id = Constantes.TIPO_LOTES } });
          n.visitas = listaContadores.Count > 0 ? listaContadores[0].cont_cuenta : 0;
          bool esRemate = remate.id_rematetipo.id == Constantes.REMATETIPO_REMATE;
          bool esVentaDirecta = remate.id_tiporemate.id == Constantes.REMATETIPO_VENTA_DIRECTA;

          lista.Add(new
          {
            id_loteo = n.id_loteo,
            lo_numero = n.lo_numero,
            lo_titulo = n.lo_titulo,
            lo_descripcion = n.lo_descripcion,
            lo_minimo = n.mo_moneda + " " + n.lo_minimo.ToString("N0"),
            le_loteoestado = n.le_loteoestado,
            fa_familia = n.fa_familia,
            ca_categoria = n.ca_categoria,
            subca_subcategoria = n.subca_subcategoria,
            re_region = n.re_region,
            co_comuna = n.co_comuna,
            id_familia = n.id_familia,
            visitas = n.visitas,
            url = sUrlSitio+n.id_loteo,
            btnEliminarLote = botones.btnEliminarLote,
            notifica = (esRemate || esVentaDirecta) && NotificacionMovil.EsMovil(n.id_loteo)
          });
        }

        str_grilla.DataSource = lista;
        str_grilla.PageSize = limit;
        PageProxy pageProxy = str_grilla.Proxy[0] as PageProxy;
        if (pageProxy != null) pageProxy.Total = data.Registros;
        str_grilla.DataBind();

      }
      catch (Exception ex)
      {
        Mensajes.Error(ErrorText.ERROR_CARGAR_LISTADO_LOTES, "wf_pa_loteos_no.str_grilla_OnReadData", ex);
      }
    }