private void Desasocia(IEnumerable<Remate> list)
    {
      try
      {
        IList<co_rl_loteos> lotes = new List<co_rl_loteos>();
        IList<co_rl_loteos> listLotesPLG = new List<co_rl_loteos>();
        IList<co_re_remates> listRemates = new List<co_re_remates>();
        foreach (co_re_remates reRemates in list.Select(remate => new bf_re_remates().GetData(remate.id_remate)))
        {
          reRemates.id_remate_base = 0;
          reRemates.id_usuario_agrupa = 0;
          reRemates.rem_fechaagrupa.Fecha = DateTime.MinValue;
          listRemates.Add(reRemates);
          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 = lote.id_remate.id;
          listLotesPLG.Add(lote);
        }
        new bf_re_remates().Save(listRemates);
        new bf_rl_loteos().Save(listLotesPLG);

        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_DESAGRUPADO_EXITOSAMENTE, Mensajes.Icon.INFO);
      }
      catch (Exception ex)
      {
        throw new Exception("Desasocia: " + 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);
   }
 }
    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);
      }
    }