在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
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 }
|
请发表评论