예제 #1
0
        private void LoadDgvAllSalesProcesses()
        {
            string  token      = Session.Token;
            int     idProducer = Session.IdProfile;
            dynamic parameters = new System.Dynamic.ExpandoObject();

            if (rbForeignProcesses.Checked)
            {
                parameters.idPurchaseRequestType = 2;//EXTRANJERO
            }
            else
            {
                parameters.idPurchaseRequestType = 1;//LOCAL
            }
            parameters.idProducer = idProducer;

            var salesProcesses = VirtualFairIntegration.FindByIdPurchaseRequestTypeAndIsPublicEqualToOne(token, parameters);

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

            LimpiarGridAllSP();

            dgvAllSalesProcesses.AutoGenerateColumns = false;

            if (salesProcesses.countRows != 0)
            {
                foreach (var item in salesProcesses.purchaseRequests)
                {
                    AdminApi salesProcessesAll = new AdminApi();
                    salesProcessesAll.id       = Convert.ToInt32(item.id.ToString());
                    salesProcessesAll.email    = item.totalWeight.ToString();
                    salesProcessesAll.dateA    = item.desiredDate;
                    salesProcessesAll.fullName = item.purchaseRequestStatus.name.ToString();
                    lstAll.Add(salesProcessesAll);
                }

                dgvAllSalesProcesses.DataSource = lstAll;
            }

            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 = "Peso Total Kg";
                }
                else if (item == "dateA")
                {
                    dataGrid.HeaderText = "Fecha Decisión";
                }
                else if (item == "fullName")
                {
                    dataGrid.HeaderText = "Estado";
                }

                dataGrid.Name = item;

                dgvAllSalesProcesses.Columns.Add(dataGrid);
            }

            DataGridViewButtonColumn verDetalles1 = new DataGridViewButtonColumn();

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

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