Guest User

Untitled

a guest
Aug 9th, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.71 KB | None | 0 0
  1. require 'mysql'
  2.     class Mymethbutton < Shoes::Button
  3. @mysql_obj=Mysql.new("localhost","programm","password","work2")
  4. @ticket_id_number=""
  5. @string=""
  6. @res=""
  7.  
  8.  
  9.  
  10. def initialize(tin)
  11.  
  12.     @ticket_id_number=tin
  13.     @string="delete from quests ticket_id='"+@ticket_id_number+"';"
  14. puts "1"
  15.     super("hello")
  16.  
  17.     self.click{@res=@mysql_obj.query(@string)}
  18.    
  19.          puts @string,@res
  20. end
  21. #   zen="delete from quests where ticket_id='"+@ticket_id_number+"';
  22.    
  23.  
  24.  
  25.  
  26.     end
  27. Shoes.app :width=>420 , :height => 310 do
  28.     mysql_obj=Mysql.new("localhost","programm","password","work2")
  29.  
  30.     background "#123056".."#000000", :curve => 25, :margin => 2
  31.     @magic_string=""
  32. flow do
  33.     stack do
  34.     para "   Enter text " ,:stroke=>white
  35.     @text_edit_box=edit_box :width=>400
  36.    
  37.           end
  38.     stack do
  39.         para "IP address" ,:stroke => white
  40.         @ip_line=edit_line
  41.     end
  42.     stack do
  43.         para "start time:"  ,:stroke => white
  44.         @start_time_line=edit_line
  45.     end
  46.     stack do
  47.         para "end time"  ,:stroke => white
  48.         @end_time_line=edit_line
  49.     end
  50.         @confirm_button=button ("Confirm")  do
  51. #
  52. @magic_string1="select lancers.lancer_id from lancers where lancers.lancer_id not in (select lancer_id from quests) order by rand() limit 1;"
  53. @mysql_rand_lancer=mysql_obj.query(@magic_string1)
  54. @rand_lancer_id=String.new()
  55. @mysql_rand_lancer.each_hash do |res|
  56.     @rand_lancer_id=res["lancer_id"]
  57. end
  58. #Free lancers detect
  59. puts @rand_lancer_id.size
  60. if(@rand_lancer_id.size>0) then
  61.     para "This job added for user with id =" + @rand_lancer_id , :stroke => silver
  62. @magic_string="insert into  quests select max(ticket_id)+1,'"+@rand_lancer_id+"','"+@text_edit_box.text+"','"+@ip_line.text+"','1','"+@start_time_line.text+"','"+@end_time_line.text+"' FROM quests;"
  63. mysql_obj.query(@magic_string)
  64. else
  65.     para "Please wait.All lancers are busy" ,:stroke => red
  66. end
  67. #end of free lancers detect
  68.         end
  69.         @find_completed_button=button "find completed" do
  70. para "Completed jobs:" ,:stroke => green
  71. result=mysql_obj.query("select * from quests where status = '0';")
  72.  
  73. result.each_hash do |select|
  74.     flow do
  75.         para "User ID" ,:stroke => silver
  76. @ticket_id=select['ticket_id']
  77.        
  78. para select ['lancer_id'] ,:stroke =>white
  79.         para "Need to do:" ,:stroke=>silver
  80.         para  select['text'] ,:stroke=>white
  81.             end
  82.         flow do
  83.                     para "IP:" , :stroke=>silver
  84.                     para select['ip_address'] , :stroke=>white
  85.                         end
  86.             para "Start time:" ,:stroke => silver
  87.                    para select['start_time'] ,:stroke => orange
  88.                                  
  89.                                  para "End time:"  ,:stroke => silver
  90.                                     para select['end_time']     ,:stroke => orange  
  91.  
  92.  
  93. @complete_button=Mymethbutton.new(@ticket_id)
  94. end
  95.  
  96.  
  97.         end
  98. end
  99. para "System messages:" ,:stroke => white
  100.  
  101.  
  102.  
  103.  
  104.  
  105. end
Add Comment
Please, Sign In to add comment