Ejemplo n.º 1
0
        //Subastas públicas en las que está participando el transportista.
        private void LoadAuctions()
        {
            string  token      = Session.Token;
            int     idCarrier  = Session.IdProfile;
            dynamic parameters = new System.Dynamic.ExpandoObject();

            //parameters.idPurchaseRequestType = 1;
            parameters.idCarrier = idCarrier;

            var findByIdCarrier = VirtualFairIntegration.FindByIdCarrierAndIsPublicEqualToOne(token, parameters);

            List <AdminApi> lstParticipating = new List <AdminApi>();

            dgvAuctions.AutoGenerateColumns = false;

            if (findByIdCarrier.countRows != 0)
            {
                foreach (var item in findByIdCarrier.transportAuctions)
                {
                    AdminApi users = new AdminApi();
                    //cambiar variables
                    users.id       = Convert.ToInt32(item.id.ToString());
                    users.email    = item.idPurchaseRequest.ToString();
                    users.dateA    = item.desiredDate;
                    users.fullName = item.purchaseRequest.purchaseRequestStatus.name.ToString();
                    lstParticipating.Add(users);
                }

                dgvAuctions.DataSource = lstParticipating;
            }

            string[] arrayString = new string[] { "id", "email", "dateA", "fullName" };

            foreach (var item in arrayString)
            {
                DataGridViewTextBoxColumn dataGrid = new DataGridViewTextBoxColumn();

                dataGrid.DataPropertyName = item;
                if (item == "id")
                {
                    dataGrid.HeaderText = "ID";
                }
                else if (item == "email")
                {
                    dataGrid.HeaderText = "Id Venta";
                }
                else if (item == "dateA")
                {
                    dataGrid.HeaderText = "Fecha Decisión";
                }
                else if (item == "fullName")
                {
                    dataGrid.HeaderText = "Estado";
                }

                dataGrid.Name = item;

                dgvAuctions.Columns.Add(dataGrid);
            }


            DataGridViewButtonColumn verDetalles = new DataGridViewButtonColumn();

            verDetalles.FlatStyle  = FlatStyle.Popup;
            verDetalles.HeaderText = "Ver Detalle";
            verDetalles.Name       = "Ver Detalle";
            verDetalles.UseColumnTextForButtonValue = true;
            verDetalles.Text = "Ver Detalle";

            verDetalles.Width = 80;
            if (dgvAuctions.Columns.Contains(verDetalles.Name = "Ver Detalle"))
            {
            }
            else
            {
                dgvAuctions.Columns.Add(verDetalles);
            }
        }