Esempio n. 1
0
        private void dgvTrf_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            DataGridView dgv = dgvTrf;

            dgv.SuspendLayout();
            int    n        = e.RowIndex;
            string itemCode = null;

            if (dgv.Columns[e.ColumnIndex].Name == headerCode)
            {
                itemCode = dgv.Rows[n].Cells[headerCode].Value.ToString();

                if (ifGotChild(itemCode))
                {
                    bool assembly   = dalItem.checkIfAssembly(itemCode, dt_Item);
                    bool production = dalItem.checkIfProduction(itemCode, dt_Item);

                    if (assembly && production)
                    {
                        //dgv.Rows[n].Cells[dalTrfHist.TrfItemCode].Style = new DataGridViewCellStyle { ForeColor = Color.Purple, Font = new Font(dgv.Font, FontStyle.Underline) };
                        dgv.Rows[n].Cells[headerName].Style = new DataGridViewCellStyle {
                            ForeColor = Color.Purple, Font = new Font(dgv.Font, FontStyle.Underline)
                        };
                    }
                    else if (!assembly && production)
                    {
                        //dgv.Rows[n].Cells[dalTrfHist.TrfItemCode].Style = new DataGridViewCellStyle { ForeColor = Color.Green, Font = new Font(dgv.Font, FontStyle.Underline) };
                        dgv.Rows[n].Cells[headerName].Style = new DataGridViewCellStyle {
                            ForeColor = Color.Green, Font = new Font(dgv.Font, FontStyle.Underline)
                        };
                    }
                    else
                    {
                        //dgv.Rows[n].Cells[dalTrfHist.TrfItemCode].Style = new DataGridViewCellStyle { ForeColor = Color.Blue, Font = new Font(dgv.Font, FontStyle.Underline) };
                        dgv.Rows[n].Cells[headerName].Style = new DataGridViewCellStyle {
                            ForeColor = Color.Blue, Font = new Font(dgv.Font, FontStyle.Underline)
                        };
                    }

                    if (itemCode.Substring(1, 2) == text.Inspection_Pass)
                    {
                        dgv.Rows[n].Cells[headerName].Style = new DataGridViewCellStyle {
                            ForeColor = Color.Peru, Font = new Font(dgv.Font, FontStyle.Underline)
                        };
                    }
                }
            }

            //else if (dgv.Columns[e.ColumnIndex].Name == headerResult)
            //{
            //    if (dgv.Rows[n].Cells[headerResult].Value != null)
            //    {
            //        if (dgv.Rows[n].Cells[headerResult].Value.ToString().Equals("Undo"))
            //        {
            //            dgv.Rows[n].DefaultCellStyle.ForeColor = Color.Red;
            //            dgv.Rows[n].DefaultCellStyle.Font = new Font(Font, FontStyle.Strikeout);
            //        }
            //        else if (dgv.Rows[n].Cells[headerResult].Value.ToString().Equals("Failed"))
            //        {
            //            dgv.Rows[n].DefaultCellStyle.ForeColor = Color.Red;
            //            //dgv.Rows[n].DefaultCellStyle.Font = new Font(Font, FontStyle.Strikeout);
            //        }
            //        else
            //        {
            //            dgv.Rows[n].DefaultCellStyle.ForeColor = Color.Black;
            //            dgv.Rows[n].DefaultCellStyle.Font = new Font(Font, FontStyle.Regular);
            //        }
            //    }
            //}


            dgv.ResumeLayout();
        }