private void TextBlock_MouseLeftButtonDown_1(object sender, MouseButtonEventArgs e) { LogWind main = new LogWind(); main.Show(); this.Close(); }
private void back(object sender, MouseButtonEventArgs e) { LogWind logWind = new LogWind(); logWind.Show(); this.Close(); }
private void registration(object sender, RoutedEventArgs e) { string pattern = @"^(?("")(""[^""]+?""@)|(([0-9a-z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-z])@))" + @"(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-z][-\w]*[0-9a-z]*\.)+[a-z0-9]{2,17}))$"; SqlConnection con = new SqlConnection(); con.ConnectionString = ConfigurationManager.ConnectionStrings["connList"].ConnectionString; con.Open(); SqlCommand cmd = new SqlCommand(); cmd.CommandText = "Select * from Libing where Id = '" + Convert.ToInt32(Id.Text) + "'"; cmd.Connection = con; SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(cmd); DataTable check = new DataTable(); sqlDataAdapter.Fill(check); if (check.Rows.Count == 1) { cmd.CommandText = "Select * from Students where Id = '" + Convert.ToInt32(Id.Text) + "'"; cmd.Connection = con; sqlDataAdapter = new SqlDataAdapter(cmd); check = new DataTable(); sqlDataAdapter.Fill(check); if (check.Rows.Count == 0) { cmd.CommandText = "Select * from Students where Login = '******'"; cmd.Connection = con; sqlDataAdapter = new SqlDataAdapter(cmd); check = new DataTable(); sqlDataAdapter.Fill(check); if (check.Rows.Count == 0) { if (Regex.IsMatch(Em.Text, pattern, RegexOptions.IgnoreCase)) { try { cmd = new SqlCommand(); cmd.CommandText = "Insert into Students (Login, Password, Id, Email) " + "values ('" + Log.Text + "', '" + Convert.ToInt32(Pass.Password) + "', '" + Convert.ToInt32(Id.Text) + "', '" + Em.Text + "' )"; cmd.Connection = con; SqlDataAdapter da = new SqlDataAdapter(cmd); da.SelectCommand.ExecuteNonQuery(); MessageBox.Show("Учётная запись создана"); LogWind logWind = new LogWind(); logWind.Show(); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { con.Close(); } } else { MessageBox.Show("Email введён некорректно."); } } else { MessageBox.Show("Пользователь с таким логином уже сужествует."); } } else { MessageBox.Show("У Вас уже есть учётная запись."); } } else { MessageBox.Show("Студенческий введён некорректно."); } }