private void button3_Click(object sender, EventArgs e) { this.Hide(); ListBrands main = new ListBrands(mainClient); main.Closed += (s, args) => this.Close(); main.Show(); }
private void button1_Click(object sender, EventArgs e) { //check for email first Regex regex = new Regex(pattern); Match match = regex.Match(textBox4.Text); if (String.IsNullOrEmpty(textBox1.Text) || String.IsNullOrEmpty(textBox2.Text) || String.IsNullOrEmpty(textBox3.Text) || String.IsNullOrEmpty(textBox4.Text) || String.IsNullOrEmpty(textBox5.Text) ) { MessageBox.Show("Моля попълнете всички полета за да продължите"); } else { if (match.Success) { //check for phone number Regex phone_regex = new Regex(@"^[0-9]+$"); Match phone_match = phone_regex.Match(textBox3.Text); if (phone_match.Success && textBox3.Text.Length == 10) { if (IsNumeric(textBox5.Text) || Int32.TryParse(textBox5.Text, out int val)) { decimal dec = Math.Round(Decimal.Parse(textBox5.Text), 2); this.Hide(); client = new Client(textBox1.Text, textBox2.Text, textBox3.Text, textBox4.Text, dec); Database db = new Database(); db.InsertClient(client.name, client.address, client.phone, client.email, client.money); var form = new ListBrands(client); form.Closed += (s, args) => this.Close(); form.Show(); } else { MessageBox.Show("Моля въведете правилно полето за налични пари.\n" + "Пример : 123,23 / 123"); } } else { MessageBox.Show("Моля въведете правилно полето за телефонен номер"); } } else { MessageBox.Show("Моля въведете правилно полето за Имейл"); } } }
private void button2_Click(object sender, EventArgs e) { //check for email first Regex regex = new Regex(pattern); Match match = regex.Match(textBox2.Text); if (String.IsNullOrEmpty(textBox1.Text) || String.IsNullOrEmpty(textBox2.Text)) { MessageBox.Show("Please fill all the inputs to continue"); } else if (match.Success) { Regex phone_regex = new Regex(@"^[0-9]+$"); Match phone_match = phone_regex.Match(textBox1.Text); if (phone_match.Success && textBox1.Text.Length == 10) { Database db = new Database(); int hasClients = db.SelectClients(textBox2.Text, textBox1.Text); if (hasClients > 0) { Client mainClient = db.GetClientAfterLog(textBox2.Text, textBox1.Text); this.Hide(); ListBrands form = new ListBrands(mainClient); form.Closed += (s, args) => this.Close(); form.Show(); } else { MessageBox.Show("Не съществува такъв клиент.Моля проверете отново въведените данни."); } } else { MessageBox.Show("Моля попълнете коректни данни."); } } }