1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace WindowsFormsAppGrishina
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- Form2 Form2 = new Form2();
- Form2.Show();
- }
- private void button2_Click(object sender, EventArgs e)
- {
- if (string.IsNullOrEmpty(TextBoxLogin.Text) || string.IsNullOrEmpty(PasswordBox.Text))
- {
- MessageBox.Show("Введите логин и пароль");
- return;
- }
- using (var db = new UserEntities())
- {
- var user = db.User
- .AsNoTracking()
- .FirstOrDefault(u => u.Login == TextBoxLogin.Text && u.Pass == PasswordBox.Text);
- if (user == null)
- {
- MessageBox.Show("Пользователь с такими данными не найден");
- return;
- }
- MessageBox.Show("Пользователь найден");
- }
- }
- }
- }
|