Goran Bibic

Goran Bibic

  • 482
  • 2.9k
  • 197.1k

Case when if is time sequence 5 minutes from sql c#

Apr 4 2018 5:55 AM
If worker come to company 5 minutes and
 
  1. if (Int32.Parse(queryString) != 0)  
  2.                {  
  3.                    //provjeravamo da li se radnik mozda prijavio prije 5 minuta, samim tim nema pravo na odjavu a ni na novu prijavu  
  4.                    string commanda = "SELECT CASE WHEN (SELECT FLOOR(TIME_TO_SEC(TIMEDIFF(now(),max(VrijemeDolaska)))/60) from prijava_radnika where IdPosjetioc=" + osobaId + ") < 5 THEN 1 ELSE 0 END;";  
  5.                    //MessageBox.Show(commanda);  
  6.                    int broj = Int32.Parse.Execute(commanda));  
  7.                    commanda = "SELECT CASE WHEN (SELECT FLOOR(TIME_TO_SEC(TIMEDIFF(now(),max(VrijemeOdlaska)))/60) from prijava_radnika where IdPosjetioc=" + osobaId + ") < 5 THEN 1 ELSE 0 END;";  
  8.                    int broj2 = Int32.Parse.Execute(commanda));
     
  9.                    //MessageBox.Show(broj.ToString());  
  10.                    if (broj == 1 || broj2 == 1)  
  11.                    {  
  12.                        notificationPanel.BackColor = System.Drawing.ColorTranslator.FromHtml("#FD7400");  
  13.                        messageLabel.Text = "Prijava i odjava su blokirani 5 minuta \nza ovog radnika";  
  14.                        textBox1.Text = "";  
  15.                    }  
  16.                    else  
  17.                    {   //rest code of app....
 

Answers (26)