Ejemplo n.º 1
0
 protected void ddlUsuario_SelectedIndexChanged(object sender, EventArgs e)
 {
     int AuctionId = (int)ViewState["AuctionID"];
     SubastaBLL bl = new SubastaBLL();
     int opcion = Convert.ToInt32(ddlUsuario.SelectedValue);
     if (opcion == 0)
     {
         List<AuctionRecord> lstRecord = new List<AuctionRecord>();
         lstRecord = bl.cargarAuctionrecord(AuctionId);
         ViewState["lstRecord"] = lstRecord;
         grdHistorial.DataSource = lstRecord;
         grdHistorial.DataBind();
         suma();
     }
     else
     {
         opcion = Convert.ToInt32(ddlUsuario.SelectedValue);
         List<AuctionRecord> lstRecord = new List<AuctionRecord>();
         lstRecord = bl.CargarDDLGRID(AuctionId, opcion);
         ViewState["lstRecord"] = lstRecord;
         grdHistorial.DataSource = lstRecord;
         grdHistorial.DataBind();
         suma();
     }
 }
Ejemplo n.º 2
0
        public void cargarSubastas() {

            SubastaBLL bl = new SubastaBLL();

            List<Auction> lstsubasta = new List<Auction>();

            lstsubasta = bl.cargarSubastas();

            grdSubasta.DataSource = lstsubasta;
            grdSubasta.DataBind();

        }
Ejemplo n.º 3
0
 public void cargarHistorial(int AuctionID)
 {
         SubastaBLL bl = new SubastaBLL();
         Auction subasta = new Auction();
         subasta = bl.cargarSubastaHistorial(AuctionID);
         txtProducto.Text = subasta.ProductName;
         txtDescripcion.Text = subasta.Description;
         List<AuctionRecord> lstRecord = new List<AuctionRecord>();
         lstRecord = bl.cargarAuctionrecord(AuctionID);
         ViewState["lstRecord"] = lstRecord;
         grdHistorial.DataSource = lstRecord;
         grdHistorial.DataBind();
         ScriptManager.RegisterStartupScript(this, typeof(Page), "calculateTotal", "calculateTotal()", true);
     }
Ejemplo n.º 4
0
        protected void btnGuardar_Click(object sender, EventArgs e)
        {
            decimal ofertaAcutual = Convert.ToDecimal(txtOfertaActual.Text);
            decimal oferta = Convert.ToDecimal(txtOfertar.Text);
            DateTime fechaInicio;
            DateTime fechaFinal;
            DateTime FechaActual;
            FechaActual= DateTime.Now;
            fechaInicio = Convert.ToDateTime(txtInicio.Text);
            fechaFinal = Convert.ToDateTime(txtFin.Text);
            if (fechaInicio <= FechaActual && fechaFinal >= FechaActual)
            {
                if (ofertaAcutual < oferta)
                {
                    SubastaBLL bl = new SubastaBLL();
                    Auction subasta = new Auction();
                    AuctionRecord record = new AuctionRecord();
                    subasta.AuctionId = Convert.ToInt32(txtNumSubasta.Text);
                    subasta.ProductName = txtNombre.Text;
                    subasta.Description = txtDescripcion.Text;
                    subasta.StartDate = Convert.ToDateTime(txtInicio.Text);
                    subasta.EndDate = Convert.ToDateTime(txtFin.Text);
                    subasta.HighestBid = Convert.ToDecimal(txtOfertar.Text);
                    User user = new User();
                    user = (User)Session["User"];
                    subasta.Winner = user.UserId;
                    bl.UpdateSubasta(subasta);
                    record.AuctionId = Convert.ToInt32(txtNumSubasta.Text);
                    record.UserId = user.UserId;
                    record.Amount = Convert.ToDecimal(txtOfertar.Text);
                    record.BidDate = Convert.ToDateTime(FechaActual);
                    bl.AgregarAuctionRecord(record);
                    ClientScript.RegisterStartupScript(this.GetType(), "alerta", "alert('La oferta se realizo corretamente')", true);
                }
                else
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "alerta", "alert('La oferta debe ser mayor a la actual')", true);
                }
            }
            else {
                ClientScript.RegisterStartupScript(this.GetType(), "alerta", "alert('Error, La subasta Estara disponible en las fechas marcadas')", true);
            }


        }
Ejemplo n.º 5
0
 protected void btnGuardar_Click(object sender, EventArgs e)
 {
     SubastaBLL bl = new SubastaBLL();
     DateTime fechaActual = DateTime.Now;
     DateTime fechaInicio = Convert.ToDateTime(txtInicio.Text);
     DateTime fechaFin = Convert.ToDateTime(txtFin.Text);
     List<Auction> lstSubastas = new List<Auction>();
     User User = (User)Session["User"];
     int id = User.UserId;
     int conteo = 0;
     lstSubastas = bl.ConteoDeSubastas(id);
     foreach(Auction subasta in lstSubastas){
         if (subasta.StartDate < Convert.ToDateTime(txtInicio.Text) && subasta.EndDate > Convert.ToDateTime(txtInicio.Text))
         {
             conteo++;
         }
     }
     if (conteo >= 3) {
         ClientScript.RegisterStartupScript(this.GetType(), "alerta", "alert('No se pueden tener mas de 3 subastas activas sumultaneamente')", true);
     }
     else
     {
         if (fechaInicio >= fechaActual && fechaFin > fechaInicio)
         {
             Auction subasta = new Auction();
             subasta.ProductName = txtNombre.Text;
             subasta.Description = txtDescripcion.Text;
             subasta.StartDate = Convert.ToDateTime(txtInicio.Text);
             subasta.EndDate = Convert.ToDateTime(txtFin.Text);
             subasta.UserId = id;
             subasta.HighestBid = 0;
             bl.AgregarNuevaSubasta(subasta);
             ClientScript.RegisterStartupScript(this.GetType(), "alerta", "alert('Subasta Agregada Exitosamente')", true);
         }
         else {
             ClientScript.RegisterStartupScript(this.GetType(), "alerta", "alert('La fecha de incio de la subasta debe ser despues de hoy y la final despues de la de inicio')", true);
         }
     }
 }
Ejemplo n.º 6
0
 public void cargarSubasta(int id) {
     SubastaBLL bl = new SubastaBLL();
     Auction subasta = new Auction();
     subasta = bl.cargarSubastaEspecifico(id);
     int? IdUser = subasta.Winner;
     if (IdUser != null)
     {
         User usuario = new User();
         usuario = bl.cargarNombreUsuario(IdUser);
         txtUsuarioOferta.Text = usuario.Name;
     }
     else
     {
         txtUsuarioOferta.Text = subasta.Winner.ToString();
     }
     txtNumSubasta.Text = subasta.AuctionId.ToString();
     txtNombre.Text = subasta.ProductName.ToString();
     txtDescripcion.Text = subasta.Description.ToString();
     txtInicio.Text = subasta.StartDate.ToShortDateString();
     txtFin.Text = subasta.EndDate.ToShortDateString();
     txtOfertaActual.Text = subasta.HighestBid.ToString();
     User user = new User();
     user = (User)Session["User"];
 }
Ejemplo n.º 7
0
        public void cargarDdlUsuario()
        {
            SubastaBLL bl = new SubastaBLL();
            List<AuctionRecord> lstRecord = new List<AuctionRecord>();
            lstRecord = (List<AuctionRecord>)ViewState["lstRecord"];
            List<User> lstUser = new List<User>();
            
            foreach (AuctionRecord rec in lstRecord)
            {
                User usuario = new User();
                usuario = rec.User;
                User prod = lstUser.Find(p => p.UserName == usuario.UserName);
                if(prod != null){
                }else{
                lstUser.Add(usuario);
                }
            }
            ddlUsuario.DataTextField = "UserName";
            ddlUsuario.DataValueField = "UserId";
            ddlUsuario.DataSource = lstUser;
            ddlUsuario.DataBind();
            ddlUsuario.Items.Insert(0, new ListItem("Seleccione ..", "0"));

        }
Ejemplo n.º 8
0
        public void cargarFiltro() 
        {
            SubastaBLL bl = new SubastaBLL();

            List<Auction> lstsubasta = new List<Auction>();
        }