Guest User

Untitled

a guest
Aug 15th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. for (int i = 0; i < dataGridView1.Rows.Count; i++)
  2. {
  3.  
  4. for (int k = 0; k < 2; k++)
  5. {
  6. if (dataGridView1[k, i].Value != null)
  7. {
  8. DateTime dateTime = DateTime.UtcNow.Date;
  9. var tomorrow = dateTime.AddDays(1);
  10. var tom1 = dateTime.AddDays(2);
  11. var tom2 = dateTime.AddDays(3);
  12. string data = dataGridView1.Rows[i].Cells[6].Value.ToString();
  13. string dateVal = Convert.ToDateTime(dataGridView1[k, i].Value).ToString("MM/dd/yyyy");
  14. PdfPCell cellc = new PdfPCell(new Phrase(dateVal, fontTable));
  15. if (dateVal == dateTime.ToString("MM/dd/yyyy") && data != "FIN - ENIG ")
  16. {
  17. cellc.BackgroundColor = new iTextSharp.text.Color(0, 240, 240);
  18. pdfTable.DefaultCell.BackgroundColor = BaseColor.LIGHT_GRAY;
  19. }
  20. else if (data != "FIN - ENIG " && dateVal == tomorrow.ToString("MM/dd/yyyy"))
  21. {
  22. cellc.BackgroundColor = new iTextSharp.text.Color(0, 240, 240);
  23. pdfTable.DefaultCell.BackgroundColor = BaseColor.LIGHT_GRAY;
  24. }
  25. else if (data != "FIN - ENIG " && dateVal == tom1.ToString("MM/dd/yyyy"))
  26. {
  27. cellc.BackgroundColor = new iTextSharp.text.Color(0, 240, 240);
  28. pdfTable.DefaultCell.BackgroundColor = BaseColor.LIGHT_GRAY;
  29. }
  30. else if (data != "FIN - ENIG " && dateVal == tom2.ToString("MM/dd/yyyy"))
  31. {
  32. cellc.BackgroundColor = new iTextSharp.text.Color(0, 240, 240);
  33. pdfTable.DefaultCell.BackgroundColor = BaseColor.LIGHT_GRAY;
  34. }
  35. else
  36. {
  37.  
  38.  
  39.  
  40. // pdfTable.DefaultCell.BackgroundColor = BaseColor.WHITE;
  41. }
  42.  
  43. pdfTable.AddCell(cellc);
  44. }
  45.  
  46. }
Add Comment
Please, Sign In to add comment