Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'mysql'
- class Mymethbutton < Shoes::Button
- @mysql_obj=Mysql.new("localhost","programm","password","work2")
- @ticket_id_number=""
- @string=""
- @res=""
- def initialize(tin)
- @ticket_id_number=tin
- @string="delete from quests ticket_id='"+@ticket_id_number+"';"
- puts "1"
- super("hello")
- self.click{@res=@mysql_obj.query(@string)}
- puts @string,@res
- end
- # zen="delete from quests where ticket_id='"+@ticket_id_number+"';
- end
- Shoes.app :width=>420 , :height => 310 do
- mysql_obj=Mysql.new("localhost","programm","password","work2")
- background "#123056".."#000000", :curve => 25, :margin => 2
- @magic_string=""
- flow do
- stack do
- para " Enter text " ,:stroke=>white
- @text_edit_box=edit_box :width=>400
- end
- stack do
- para "IP address" ,:stroke => white
- @ip_line=edit_line
- end
- stack do
- para "start time:" ,:stroke => white
- @start_time_line=edit_line
- end
- stack do
- para "end time" ,:stroke => white
- @end_time_line=edit_line
- end
- @confirm_button=button ("Confirm") do
- #
- @magic_string1="select lancers.lancer_id from lancers where lancers.lancer_id not in (select lancer_id from quests) order by rand() limit 1;"
- @mysql_rand_lancer=mysql_obj.query(@magic_string1)
- @rand_lancer_id=String.new()
- @mysql_rand_lancer.each_hash do |res|
- @rand_lancer_id=res["lancer_id"]
- end
- #Free lancers detect
- puts @rand_lancer_id.size
- if(@rand_lancer_id.size>0) then
- para "This job added for user with id =" + @rand_lancer_id , :stroke => silver
- @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;"
- mysql_obj.query(@magic_string)
- else
- para "Please wait.All lancers are busy" ,:stroke => red
- end
- #end of free lancers detect
- end
- @find_completed_button=button "find completed" do
- para "Completed jobs:" ,:stroke => green
- result=mysql_obj.query("select * from quests where status = '0';")
- result.each_hash do |select|
- flow do
- para "User ID" ,:stroke => silver
- @ticket_id=select['ticket_id']
- para select ['lancer_id'] ,:stroke =>white
- para "Need to do:" ,:stroke=>silver
- para select['text'] ,:stroke=>white
- end
- flow do
- para "IP:" , :stroke=>silver
- para select['ip_address'] , :stroke=>white
- end
- para "Start time:" ,:stroke => silver
- para select['start_time'] ,:stroke => orange
- para "End time:" ,:stroke => silver
- para select['end_time'] ,:stroke => orange
- @complete_button=Mymethbutton.new(@ticket_id)
- end
- end
- end
- para "System messages:" ,:stroke => white
- end
Add Comment
Please, Sign In to add comment