zoukankan      html  css  js  c++  java
  • C#



     1 private void gvSendConfirm_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
     2         {
     3             string sCurrTime=DbHelperSql.GetSingle("Select GetDate() DateNow").ToString();
     4             DateTime dtCurrTime,dtSendTime;
     5             int iMinutes = 0;
     6             try
     7             {
     8                 dtCurrTime=DateTime.Parse(sCurrTime);
     9             }
    10             catch (System.Exception ex)
    11             {
    12             dtCurrTime=DateTime.Now;
    13             }
    14 
    15             string sSendTime= gvSendConfirm.GetDataRow(e.RowHandle)["UpdateTime"].ToString();
    16             try
    17             {
    18                 dtSendTime = DateTime.Parse(sSendTime);
    19             }
    20             catch (System.Exception ex)
    21             {
    22                 dtSendTime = DateTime.Now;
    23             }
    24 
    25             //计算时间差。
    26             System.TimeSpan difTime = dtCurrTime.Subtract(dtSendTime);
    27             iMinutes = difTime.Minutes;
    28 
    29             if (iMinutes <= iTimeOutLevel1)
    30             {
    31                 e.Appearance.BackColor = Color.White;   //设置背景色
    32             }
    33             else if (iMinutes > iTimeOutLevel1 && iMinutes <= iTimeOutLevel2)
    34             {
    35                 e.Appearance.BackColor = Color.FromArgb(192, 192, 255);//设置背景色
    36             }
    37             else if (iMinutes > iTimeOutLevel2 && iMinutes <= iTimeOutLevel3)
    38             {
    39                 e.Appearance.BackColor = Color.FromArgb(128, 255, 128);//设置背景色
    40             }
    41             else if (iMinutes > iTimeOutLevel3 && iMinutes <= iTimeOutLevel4)
    42             {
    43                 e.Appearance.BackColor = Color.FromArgb(255, 192, 128);//设置背景色
    44             }
    45             else if (iMinutes > iTimeOutLevel4 && iMinutes <= iTimeOutLevel5)
    46             {
    47                 e.Appearance.BackColor = Color.FromArgb(255, 128, 128);//设置背景色
    48             }
    49             else if (iMinutes > iTimeOutLevel5 && iMinutes <= iTimeOutLevel6)
    50             {
    51                 e.Appearance.BackColor = Color.Red;//设置背景色
    52             }
    53             else if (iMinutes > iTimeOutLevel6)
    54             {
    55                 e.Appearance.BackColor = Color.Crimson;//设置背景色
    56             }
    57             e.Appearance.ForeColor = Color.Black; //设置字体颜色
    58         }
  • 相关阅读:
    剑指offer(14)链表中倒数第K个节点
    剑指offer(13)调整数组顺序使奇数位于偶数前面
    跨域资源共享CORS
    同源政策
    剑指offer(12)数值的整数次方
    剑指offer(11)二进制中1的个数
    面试金典——交点
    LeetCode——简化路径
    LeetCode——跳跃游戏 I-II
    LeetCode——最大矩形
  • 原文地址:https://www.cnblogs.com/kliine/p/9246736.html
Copyright © 2011-2022 走看看