private void button4_Click(object sender, EventArgs e) { FormRunnerProfileCoord fm = new FormRunnerProfileCoord(email, runnerEmail, registrationId); fm.Show(); this.Hide(); }
private void FormRunnersListCoord_Load(object sender, EventArgs e) { timer1.Start(); comboBox3.Text = "Any"; SqlConnection conn = new SqlConnection(Connection.GetString()); conn.Open(); SqlCommand commandCount = new SqlCommand("SELECT COUNT(Email) as c FROM Users WHERE RoleId = 'R'", conn); using (SqlDataReader reader = commandCount.ExecuteReader()) { while (reader.Read()) { label10.Text = reader["c"].ToString(); } } SqlCommand commandStatus = new SqlCommand("SELECT * FROM RegistrationStatus", conn); using (SqlDataReader reader = commandStatus.ExecuteReader()) { while (reader.Read()) { ComboBoxItem item = new ComboBoxItem(); item.text = reader["RegistrationStatus"].ToString(); item.value = reader["RegistrationStatusId"].ToString(); comboBox1.Items.Add(item); comboBox1.Text = "Any"; } } SqlCommand commandDistance = new SqlCommand("SELECT * FROM EventType", conn); using (SqlDataReader reader = commandDistance.ExecuteReader()) { while (reader.Read()) { ComboBoxItem item = new ComboBoxItem(); item.text = reader["EventTypeName"].ToString(); item.value = reader["EventTypeId"].ToString(); comboBox2.Items.Add(item); comboBox2.Text = "Any"; } } SqlCommand command = new SqlCommand("SELECT TOP(400) Registration.RegistrationId, Users.FirstName, Users.LastName, Users.Email,RegistrationStatus.RegistrationStatus FROM RegistrationStatus, Registration, Runner, Users WHERE Users.Email = Runner.Email AND Users.RoleId = 'R' AND Runner.RunnerId = Registration.RunnerId AND Registration.RegistrationStatusId = RegistrationStatus.RegistrationStatusId", conn); using (SqlDataReader reader = command.ExecuteReader()) { int z = 0; while (reader.Read()) { TextBox tx1 = new TextBox(); tx1.Size = textBox1.Size; tx1.Font = textBox1.Font; tx1.Location = new Point(textBox1.Location.X, textBox1.Location.Y + z); tx1.Text = reader["LastName"].ToString(); tx1.ReadOnly = true; panel1.Controls.Add(tx1); TextBox tx2 = new TextBox(); tx2.Size = textBox2.Size; tx2.Font = textBox2.Font; tx2.Location = new Point(textBox2.Location.X, textBox2.Location.Y + z); tx2.Text = reader["FirstName"].ToString(); tx2.ReadOnly = true; panel1.Controls.Add(tx2); TextBox tx3 = new TextBox(); tx3.Size = textBox3.Size; tx3.Font = textBox3.Font; tx3.Location = new Point(textBox3.Location.X, textBox3.Location.Y + z); tx3.Text = reader["Email"].ToString(); tx3.ReadOnly = true; panel1.Controls.Add(tx3); TextBox tx4 = new TextBox(); tx4.Size = textBox4.Size; tx4.Font = textBox4.Font; tx4.Location = new Point(textBox4.Location.X, textBox4.Location.Y + z); tx4.Text = reader["RegistrationStatus"].ToString(); tx4.ReadOnly = true; panel1.Controls.Add(tx4); Button bn = new Button(); bn.Size = button6.Size; bn.Location = button6.Location; bn.Text = "Edit"; bn.Font = button6.Font; bn.Tag = reader["Email"].ToString(); bn.TabIndex = Convert.ToInt32(reader["RegistrationId"]); bn.Location = new Point(button6.Location.X, button6.Location.Y + z); bn.Click += (ee, aa) => { //MessageBox.Show(bn.Tag.ToString() + " " + bn.TabIndex); FormRunnerProfileCoord fm = new FormRunnerProfileCoord(email, bn.Tag.ToString(), bn.TabIndex.ToString()); fm.Show(); this.Hide(); }; panel1.Controls.Add(bn); z += 26; } } }
private void button5_Click(object sender, EventArgs e) { bool changePass = false; if (textBox2.Text != "" || textBox3.Text != "") { changePass = true; } if (textBox4.Text == "" || textBox5.Text == "" || comboBox1.Text == "" || comboBox2.Text == "") { MessageBox.Show("Одно или несколько обязательных полей для ввода (отмеченных знаком *) не были заполнены!", "Оповещение системы"); } else { bool digit = false; bool spec = false; bool lowChar = false; bool pass = false; bool cpass = false; if (changePass) { for (int i = 0; i < textBox2.TextLength; i++) { if (Char.IsDigit(textBox2.Text[i])) { digit = true; break; } } for (int i = 0; i < textBox2.TextLength; i++) { if (Char.IsLower(textBox2.Text[i])) { lowChar = true; break; } } for (int i = 0; i < textBox2.TextLength; i++) { if (textBox2.Text[i] == '#' || textBox2.Text[i] == '!' || textBox2.Text[i] == '@' || textBox2.Text[i] == '$' || textBox2.Text[i] == '%' || textBox2.Text[i] == '^') { spec = true; break; } } if (textBox2.TextLength < 6 || !spec || !digit || !lowChar) { MessageBox.Show("Некорректный формат пароля! Длина пароля должна быть не менее шести символов, из которых должна быть, как минимум, одна буква нижнего регистра, одна цифра и один из следующих символов: !,#,%,^,@", "Оповещение системы"); } else { pass = true; } if (pass) { if (textBox2.Text != textBox3.Text) { MessageBox.Show("Пароли не совпадают!", "Оповещение системы"); } else { changePass = false; cpass = true; } } } if (changePass == false) { DateTime dateOfBirth = Convert.ToDateTime(dateTimePicker1.Value); if (DateTime.Now.Year - dateOfBirth.Year < 10) { MessageBox.Show("Возраст бегуна на момент регистрации должен быть не менее 10ти лет!", "Оповещение системы"); } else { SqlConnection conn = new SqlConnection(Connection.GetString()); conn.Open(); SqlCommand command = new SqlCommand("UPDATE Users Set FirstName = '" + textBox5.Text + "', LastName = '" + textBox4.Text + "', Picture = '" + textBox6.Text + "' WHERE Email = '" + runnerEmail + "'", conn); command.ExecuteNonQuery(); SqlCommand command2 = new SqlCommand("UPDATE Runner Set Gender = '" + (comboBox1.SelectedItem as ComboBoxItem).value + "', CountryCode = '" + (comboBox2.SelectedItem as ComboBoxItem).value + "' WHERE Email = '" + runnerEmail + "'", conn); command2.ExecuteNonQuery(); SqlCommand command3 = new SqlCommand("UPDATE Registration Set RegistrationStatusId = '" + (comboBox3.SelectedItem as ComboBoxItem).value + "' WHERE RegistrationId = '" + registrationId + "'", conn); command3.ExecuteNonQuery(); if (cpass) { SqlCommand command4 = new SqlCommand("UPDATE Users Set Password = '******' WHERE Email = '" + email + "'", conn); command4.ExecuteNonQuery(); } try { Bitmap bmp = new Bitmap(openFileDialog1.FileName); bmp.Save("picture/" + openFileDialog1.SafeFileName); } catch (Exception ex) { } MessageBox.Show("Профиль бегуна успешно изменен!", "Оповещение системы"); FormRunnerProfileCoord fm = new FormRunnerProfileCoord(email, runnerEmail, registrationId); fm.Show(); this.Hide(); } } } }