Guest User

Untitled

a guest
Jan 21st, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. var now = DateTime.Now;
  2. var expirationDate = DateTime.Parse(row.Cells[2].Value.ToString());
  3. var TwentyOneDays = expirationDate.AddDays(-21);
  4.  
  5. var TenDays = expirationDate.AddDays(-10);
  6.  
  7. if (now > TwentyOneDays && now < expirationDate)
  8. {
  9. row.DefaultCellStyle.BackColor = Color.LightSkyBlue;
  10. row.Cells[2].Style.BackColor = Color.Yellow;
  11.  
  12. // .....
  13. }
  14.  
  15. DateTime expirationDate = DateTime.Now.AddDays(21);
  16. DateTime now = DateTime.Now;
  17.  
  18. TimeSpan diff = expirationDate - now;
  19.  
  20. int days = diff.Days; // This would give 20
  21.  
  22. private void getexpireddate()
  23. {
  24. try
  25. {
  26. MySqlConnection con = new MySqlConnection(conn);
  27. connect.Open();
  28. string sql="SELECT expireddate FROM data1 where date(date) = date(now())";
  29. MySqlDataAdapter da = new MySqlDataAdapter(sql, con);
  30. DataTable ds = new DataTable();
  31. da.Fill(ds);
  32. datagrid.DataSource=ds;
  33.  
  34. }
  35. catch(Exception ee)
  36. {
  37. Console.WriteLine(ee.Message);
  38. }
  39. }
Add Comment
Please, Sign In to add comment