У нас вы можете посмотреть бесплатно 3 Ways of Creating a Login System | C# или скачать в максимальном доступном качестве, видео которое было загружено на ютуб. Для загрузки выберите вариант из формы ниже:
Если кнопки скачивания не
загрузились
НАЖМИТЕ ЗДЕСЬ или обновите страницу
Если возникают проблемы со скачиванием видео, пожалуйста напишите в поддержку по адресу внизу
страницы.
Спасибо за использование сервиса ClipSaver.ru
The simplest way (embedded data) to create a login system as well as the common ones (txt and databases). Subscribe! ► https://www.youtube.com/c/QuasimodoPr... Learn how to create a login system. Let’s look what you can have by the end of this video. If I enter the wrong username or password, the program will inform me about it. And if I type each of them correctly, I will get access to another window. Of course, the username and the password have to match. In this video, I will show you three ways of creating a login system. So, let’s develop such a program. Create a new Windows Forms Application. We need two labels, two textboxes, and one button. A login window is usually small. Login validation will occur in the button_Click event. We need to create another window. Right click on the project in the solution explorer – add – Windows Form… Type the name and click “Add”. This may be the main window of your app which will be shown, if users pass the validation. Let’s change the “Backcolor” property of this window. Double-click on the square next to the property name. Now, let’s modify the button-click event. We need to create an instance of the second window. Type “Form2 f2 = new Form2 ();” And now we must display it. f2.ShowDialog(); Let’s run the program. As we can see, the window appears. But of course it must appear only when users enter correct usernames and passwords. For this purpose, we will consider three ways of achieving it and combine them. The first one is to create string arrays of usernames and passwords. It may be suitable if the program is for your personal use only. Now we will write conditions for the window’s appearance. if(usernames.Contains(textBox1.Text) && passwords.Contains(textBox2.Text) && Array.IndexOf(textBox1.Text) == Array.IndexOf (textBox2.Text) { Form2 f2 = new Form2 (); f2.ShowDialog();} We need to specify the array in which we search for the index. Let’s run the app. Everything works. Now, we’ll make the app show a messageBox which will be shown if users enter incorrect usernames and/or passwords. The second way is to store the usernames and passwords in a txt file. Of course, you should not keep it in the same folder where the app is, but we will do so just for convenience. Let’s write two usernames and passwords in a file separating them by a space symbol. Save it and close. The app will read the txt file when it starts. I prefer using StreamReader to read files. Type the name of the txt file and its extension. The app will read it line by line. Create a while-loop. While((line = sr.ReadLine()) != null){ do something;} Let’s store these usernames and passwords in two lists of strings. First, declare them. I’ll name the first one “users”, and the second one “pass”. Now let’s return to the while-loop. Since every line in the txt file contains both a username and a password, we need to separate them. In each iteration, a string array should be declared which will be filled with two line components which are split by a space symbol. We add the first component to the list of usernames, and the second one to the list of passwords. Now we need to add new conditions such as when usernames and passwords from the lists are entered. Because the action has to be the same, just copy the two lines above. if (users.Contains.textBox1.Text && pass.Contains.textBox2.Text &&… let’s copy and paste the condition above, and modify it. Change the names of the arrays. Since this method searches arrays, we need to convert the lists to arrays. Also, always close streamreaders as soon as you finished working with them. This way of storing passwords is good if either you or a few other people, for instance within one company, use the app. Now, let’s make text in the second textbox appear as the default password character. And now we will look at the third way of storing the data – databases. We will create a new database with columns for usernames and passwords. Again, I’ll need only two samples. I will paste a common piece of code for connecting to a database and modify it. First, we will include the OleDb namespace in the .cs file. I usually deal with mdb databases, so I’ll save the database as mdb to the root folder. We need to change the “Data Source” value. Also, we should specify the columns from the table in our database. As with “streamreaders”, you should close connections when you finish with them. In a while-loop, the app will read the table line by line, adding cells’ values to the lists. Since those are lists of strings, we should convert cells’ values to strings. reddit - / learn_csharp More Windows Forms ► • C# — Windows Forms Latest code: https://github.com/QuasimodoPrograms/...