private void Form1_Load(object sender, EventArgs e) { var client = new Summator.SummatorClient("NetTcpBinding_ISummator"); List <User> users = GetUsers(); foreach (User i in users) { Console.WriteLine(i.ID + " : " + i.Login); } }
private void buttonAuthor_Click(object sender, EventArgs e) { var log = login.Text; var passw = password.Text; User newUser = new User(log, passw); int count = 0; var conn = new NpgsqlConnection(connectionString); var client = new Summator.SummatorClient("NetTcpBinding_ISummator"); try { conn.Open(); List <User> users = GetUsers(); foreach (User user in users) { if (user.Login == newUser.Login && user.Password == newUser.Password) { count++; } } if (count == 0) { Console.WriteLine("Пользователя нет в системе "); } else { Console.WriteLine("Пользователm в системе "); } count = 0; conn.Close(); } catch (Exception ex) { conn.Close(); MessageBox.Show("Ошибка " + ex.Message); } client.Close(); // ДЛЯ РЕГИСТРАЦИИ. ДОБАВЛЕНИЕ USER В БД //var log = login.Text; //var passw = password.Text; //var conn = new NpgsqlConnection(connectionString); //var client = new Summator.SummatorClient("NetTcpBinding_ISummator"); ////User newUser = new User(log, passw); //try //{ // conn.Open(); // sql = @"select* from my_insert(@_login,@_password)"; // var cmd = new NpgsqlCommand(sql, conn); // cmd.Parameters.AddWithValue(@"_login", log); // cmd.Parameters.AddWithValue(@"_password", passw); // if ((int)cmd.ExecuteScalar() == 1) // { // MessageBox.Show("Пользователь добавлен"); // } // conn.Close(); //} //catch (Exception ex) //{ // conn.Close(); // Console.WriteLine("Ошибка" + ex.Message); // MessageBox.Show("Ошибка при добавлении : " + ex.Message); //} //client.Close(); }