Beispiel #1
0
        private BunifuCards[] createCard(DataTable POs)
        {
            List <BunifuCards> bunifuCardsList = new List <BunifuCards>();

            foreach (DataRow row1 in POs.Rows)
            {
                BunifuCards bunifuCards = new BunifuCards();
                bunifuCards.Size         = new Size(420, 380);
                bunifuCards.BackColor    = Color.White;
                bunifuCards.BorderRadius = 35;
                bunifuCards.Margin       = new Padding(20, 0, 20, 20);
                this.toolTip1.SetToolTip((Control)bunifuCards, "Orden #" + row1["ID_PO"].ToString());
                if (!Convert.ToBoolean(row1["Estado de Pago"]) && !Convert.ToBoolean(row1["Mercancia Recibida"]) && DateTime.Today.Date <= Convert.ToDateTime(row1["Fecha de Llegada"]).Date)
                {
                    bunifuCards.color = Color.FromArgb(0, 130, 170);
                }
                else if (!Convert.ToBoolean(row1["Estado de Pago"]) && !Convert.ToBoolean(row1["Mercancia Recibida"]))
                {
                    bunifuCards.color = Color.Orange;
                }
                else if (!Convert.ToBoolean(row1["Estado de Pago"]) && Convert.ToBoolean(row1["Mercancia Recibida"]))
                {
                    bunifuCards.color = Color.Red;
                }
                else if (Convert.ToBoolean(row1["Estado de Pago"]) && Convert.ToBoolean(row1["Mercancia Recibida"]))
                {
                    bunifuCards.color = Color.LimeGreen;
                }
                Label label1 = new Label();
                label1.Font      = new Font("Century Gothic", 22f, FontStyle.Bold);
                label1.Text      = row1["Nombre de la Empresa"].ToString();
                label1.BackColor = Color.Transparent;
                label1.AutoSize  = true;
                this.toolTip1.SetToolTip((Control)label1, "Orden #" + row1["ID_PO"].ToString());
                BunifuGradientPanel bunifuGradientPanel = new BunifuGradientPanel();
                bunifuGradientPanel.Dock = DockStyle.Top;
                bunifuGradientPanel.Controls.Add((Control)label1);
                bunifuGradientPanel.Height = 50;
                bunifuGradientPanel.Width  = bunifuCards.Width;
                this.toolTip1.SetToolTip((Control)bunifuGradientPanel, "Orden #" + row1["ID_PO"].ToString());
                bunifuGradientPanel.GradientBottomLeft  = Color.White;
                bunifuGradientPanel.GradientBottomRight = Color.White;
                bunifuGradientPanel.GradientTopLeft     = Color.White;
                bunifuGradientPanel.GradientTopRight    = Color.White;
                label1.Location = new Point((label1.Parent.Width - label1.Width) / 2, (label1.Parent.Height - label1.Height) / 2);
                bunifuCards.Controls.Add((Control)bunifuGradientPanel);
                DataGridView dataGridView = new DataGridView();
                dataGridView.BackgroundColor           = Color.White;
                dataGridView.BorderStyle               = BorderStyle.None;
                dataGridView.ScrollBars                = ScrollBars.Both;
                dataGridView.AllowUserToAddRows        = false;
                dataGridView.RowHeadersVisible         = false;
                dataGridView.EnableHeadersVisualStyles = false;
                dataGridView.ReadOnly = true;
                dataGridView.Location = new Point(0, bunifuGradientPanel.Height);
                dataGridView.Width    = bunifuCards.Width;
                dataGridView.Height   = 217;
                bunifuCards.Controls.Add((Control)dataGridView);
                dataGridView.Columns.Add("Descripción", "Descripción");
                dataGridView.Columns.Add("Cantidad", "Cantidad");
                dataGridView.Columns.Add("Precio Unitario", "Precio Unitario");
                dataGridView.Columns.Add("Total", "Total");
                dataGridView.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
                dataGridView.ColumnHeadersDefaultCellStyle.ForeColor = Color.FromArgb(0, 130, 170);
                dataGridView.ColumnHeadersDefaultCellStyle.BackColor = Color.WhiteSmoke;
                dataGridView.ColumnHeadersDefaultCellStyle.Font      = new Font("Century Gothic", 12f, FontStyle.Bold);
                dataGridView.DefaultCellStyle.Font      = new Font("Century Gothic", 12f);
                dataGridView.DefaultCellStyle.ForeColor = Color.Black;
                dataGridView.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
                foreach (DataGridViewColumn column in dataGridView.Columns)
                {
                    column.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                }
                DataTable poDetails = OrdenCompra.GetPODetails(Convert.ToInt32(row1["ID_PO"]));
                for (int index = 0; index < poDetails.Rows.Count; ++index)
                {
                    dataGridView.Rows.Add();
                    DataRow row2 = poDetails.Rows[index];
                    dataGridView[0, index].Value = row2["Descripción"];
                    dataGridView[1, index].Value = row2["Cantidad"];
                    dataGridView[2, index].Value = row2["Precio por Caja"];
                    dataGridView[3, index].Value = row2["Total"];
                }
                dataGridView.DefaultCellStyle.SelectionBackColor = Color.White;
                dataGridView.DefaultCellStyle.SelectionForeColor = Color.Black;
                Label label2 = new Label();
                label2.AutoSize  = true;
                label2.ForeColor = Color.FromArgb(0, 130, 170);
                label2.Font      = new Font("Century Gothic", 12f, FontStyle.Bold);
                DateTime dateTime = Convert.ToDateTime(row1["Fecha de Llegada"]);
                if (dateTime.Date > DateTime.Now.Date && !Convert.ToBoolean(row1["Mercancia Recibida"]))
                {
                    string monthName = new CultureInfo("es-MX").DateTimeFormat.GetMonthName(dateTime.Month);
                    string str       = monthName[0].ToString().ToUpper() + monthName.Substring(1);
                    label2.Text = "Fecha de Llegada: " + dateTime.Day.ToString() + " de " + str;
                }
                else if (dateTime.Date == DateTime.Now.Date && !Convert.ToBoolean(row1["Mercancia Recibida"]))
                {
                    string monthName = new CultureInfo("es-MX").DateTimeFormat.GetMonthName(dateTime.Month);
                    string str       = monthName[0].ToString().ToUpper() + monthName.Substring(1);
                    label2.Text      = "Fecha de Llegada: \nHoy";
                    label2.TextAlign = ContentAlignment.MiddleCenter;
                }
                else if (dateTime.Date == DateTime.Now.Date && Convert.ToBoolean(row1["Mercancia Recibida"]))
                {
                    label2.Text      = "Recibido";
                    label2.TextAlign = ContentAlignment.MiddleCenter;
                }
                else if (dateTime < DateTime.Now.Date && !Convert.ToBoolean(row1["Mercancia Recibida"]))
                {
                    label2.Text      = "No se recibió el pedido";
                    label2.ForeColor = Color.Orange;
                }
                else if (!Convert.ToBoolean(row1["Estado de Pago"]))
                {
                    label2.Text      = "Pago Pendiente";
                    label2.ForeColor = Color.Red;
                }
                else if (Convert.ToBoolean(row1["Mercancia Recibida"]))
                {
                    label2.Text      = "Completado";
                    label2.ForeColor = Color.Green;
                }
                bunifuCards.Controls.Add((Control)label2);
                label2.Location = new Point((bunifuCards.Width - label2.Width) / 2, dataGridView.Location.Y + dataGridView.Height + 20);
                BunifuThinButton2 bunifuThinButton2 = new BunifuThinButton2();
                bunifuThinButton2.Size            = new Size(180, 40);
                bunifuThinButton2.ForeColor       = Color.FromArgb(0, 130, 170);
                bunifuThinButton2.Font            = new Font("Century Gothic", 12f, FontStyle.Bold);
                bunifuThinButton2.ActiveFillColor = Color.FromArgb(0, 110, 150);
                bunifuThinButton2.ActiveForecolor = Color.White;
                bunifuThinButton2.ActiveLineColor = Color.FromArgb(0, 110, 150);
                bunifuThinButton2.IdleFillColor   = Color.White;
                bunifuThinButton2.IdleForecolor   = Color.FromArgb(0, 110, 150);
                bunifuThinButton2.IdleLineColor   = Color.FromArgb(0, 110, 150);
                bunifuCards.Controls.Add((Control)bunifuThinButton2);
                int num1 = label2.Location.Y + label2.Height;
                int num2 = bunifuCards.Height - num1;
                bunifuThinButton2.Location   = new Point((bunifuCards.Width - bunifuThinButton2.Width) / 2, (num2 - bunifuThinButton2.Height) / 2 + num1);
                bunifuThinButton2.ButtonText = "Abrir";
                bunifuThinButton2.Click     += new EventHandler(this.OpenPO);
                bunifuThinButton2.Name       = row1["ID_PO"].ToString();
                bunifuCards.Name             = dateTime.Date.ToShortDateString() + "," + row1["Nombre de la Empresa"];
                bunifuCardsList.Add(bunifuCards);
            }
            return(bunifuCardsList.ToArray());
        }