134 lines
5.4 KiB
VB.net
134 lines
5.4 KiB
VB.net
Imports System.ComponentModel
|
|
Imports System.IO
|
|
Imports System.Net
|
|
|
|
Public Class Form46
|
|
Private Sub Form46_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
|
TextBox1.Hide()
|
|
Button1.Hide()
|
|
|
|
Try
|
|
ComboBox1.Items.Clear()
|
|
Dim fwr As FtpWebRequest
|
|
fwr = FtpWebRequest.Create(ipserver & "/utilisateur/")
|
|
fwr.Credentials = New NetworkCredential("extremedownloaders", passftp)
|
|
fwr.Method = WebRequestMethods.Ftp.ListDirectory
|
|
Dim sr As New StreamReader(fwr.GetResponse().GetResponseStream())
|
|
|
|
Dim str As String = sr.ReadLine()
|
|
While Not str Is Nothing
|
|
|
|
ComboBox1.Items.Add(str)
|
|
ComboBox1.Items.Remove(nomutilisateur)
|
|
|
|
str = sr.ReadLine()
|
|
|
|
End While
|
|
|
|
|
|
sr.Close()
|
|
|
|
|
|
Catch ex As Exception
|
|
Timer1.Start()
|
|
End Try
|
|
End Sub
|
|
|
|
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
|
|
Timer1.Stop()
|
|
Try
|
|
ComboBox1.Items.Clear()
|
|
Dim fwr As FtpWebRequest
|
|
fwr = FtpWebRequest.Create(ipserver & "/utilisateur/")
|
|
fwr.Credentials = New NetworkCredential("extremedownloaders", passftp)
|
|
fwr.Method = WebRequestMethods.Ftp.ListDirectory
|
|
Dim sr As New StreamReader(fwr.GetResponse().GetResponseStream())
|
|
|
|
Dim str As String = sr.ReadLine()
|
|
While Not str Is Nothing
|
|
|
|
ComboBox1.Items.Add(str)
|
|
ComboBox1.Items.Remove(nomutilisateur)
|
|
|
|
str = sr.ReadLine()
|
|
|
|
End While
|
|
|
|
|
|
sr.Close()
|
|
|
|
|
|
Catch ex As Exception
|
|
Timer1.Start()
|
|
End Try
|
|
End Sub
|
|
|
|
Private Sub Form46_Closing(sender As Object, e As CancelEventArgs) Handles Me.Closing
|
|
TextBox1.Hide()
|
|
Button1.Hide()
|
|
ComboBox1.Show()
|
|
ComboBox1.Items.Clear()
|
|
TextBox1.Clear()
|
|
Text = "Envoyer des PB's a un autre utilisateur"
|
|
End Sub
|
|
Private Sub ComboBox1_SelectedValueChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedValueChanged
|
|
TextBox1.Show()
|
|
Button1.Show()
|
|
ComboBox1.Hide()
|
|
Text = "Envoyer des PB's a " & ComboBox1.SelectedItem
|
|
End Sub
|
|
|
|
Private Sub TextBox1_KeyPress(sender As Object, e As KeyPressEventArgs) Handles TextBox1.KeyPress
|
|
Dim desNumero() As Char = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}
|
|
If Not desNumero.Contains(e.KeyChar) And Not Asc(e.KeyChar) = 8 Then
|
|
e.Handled = True
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
|
|
My.Computer.Network.DownloadFile(ipsite & "/extrème downloaders/utilisateur/" & nomutilisateur & "/money.txt", dostemps & "money.txt")
|
|
Dim lines3() As String = File.ReadAllLines(dostemps & "money.txt")
|
|
File.Delete(dostemps & "money.txt")
|
|
Dim nombtext As Integer = 0
|
|
nombtext = TextBox1.Text
|
|
If lines3(0) < nombtext Then
|
|
MsgBox("vous n'avez pas assez de PB's" & vbNewLine & vbNewLine & "Vos PB's: " & lines3(0), MsgBoxStyle.Exclamation)
|
|
Else
|
|
Dim msg = MsgBox("voulez vous vraiment envoyer: " & TextBox1.Text & "PB's ? a " & ComboBox1.SelectedItem, MsgBoxStyle.YesNo)
|
|
If msg = MsgBoxResult.Yes Then
|
|
My.Computer.Network.DownloadFile(ipsite & "/extrème downloaders/utilisateur/" & ComboBox1.SelectedItem & "/money.txt", dostemps & "money.txt")
|
|
Dim lines1() As String = File.ReadAllLines(dostemps & "money.txt")
|
|
File.Delete(dostemps & "money.txt")
|
|
Dim sw1 As New StreamWriter(dostemps & "money.txt")
|
|
Dim moeney As Integer = 0
|
|
moeney = TextBox1.Text
|
|
Dim upmoney As Integer = lines1(0) + moeney
|
|
sw1.WriteLine(upmoney)
|
|
sw1.Close()
|
|
My.Computer.Network.UploadFile(dostemps & "money.txt", ipserver & "utilisateur/" & ComboBox1.SelectedItem & "/money.txt")
|
|
File.Delete(dostemps & "money.txt")
|
|
|
|
|
|
My.Computer.Network.DownloadFile(ipsite & "/extrème downloaders/utilisateur/" & nomutilisateur & "/money.txt", dostemps & "money.txt")
|
|
Dim lines2() As String = File.ReadAllLines(dostemps & "money.txt")
|
|
File.Delete(dostemps & "money.txt")
|
|
Dim sw2 As New StreamWriter(dostemps & "money.txt")
|
|
Dim moeney2 As Integer = 0
|
|
moeney2 = TextBox1.Text
|
|
Dim upmoney2 As Integer = lines2(0) - moeney2
|
|
sw2.WriteLine(upmoney2)
|
|
sw2.Close()
|
|
My.Computer.Network.UploadFile(dostemps & "money.txt", ipserver & "utilisateur/" & nomutilisateur & "/money.txt")
|
|
File.Delete(dostemps & "money.txt")
|
|
MsgBox("vous venez d'envoyer: " & TextBox1.Text & " PB's a " & ComboBox1.SelectedItem, MsgBoxStyle.Information)
|
|
Dim maj2 As New WebClient
|
|
Dim vri2 As String = maj2.DownloadString(ipsite & "extrème downloaders/utilisateur/" & nomutilisateur & "/money.txt")
|
|
MsgBox("il vous reste: " & vri2 & " PB's", MsgBoxStyle.Information)
|
|
Close()
|
|
Else
|
|
MsgBox("envoie annuler", MsgBoxStyle.Information)
|
|
Close()
|
|
End If
|
|
End If
|
|
End Sub
|
|
End Class |