コード例 #1
0
        private void button_Click(object sender, RoutedEventArgs e)
        {
            Clients window = new Clients();

            window.Show();
            this.Hide();
        }
コード例 #2
0
        private void buttondel_Click(object sender, RoutedEventArgs e)
        {
            if (!refresh())
            {
                return;
            }

            MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show("Are you sure you want to delete this client?", "Delete Confirmation", System.Windows.MessageBoxButton.YesNo);

            if (messageBoxResult == MessageBoxResult.Yes)
            {
                try
                {
                    SqlCommand cmd = new SqlCommand("EXEC DeleteClient " + editing.ID);
                    cmd.Connection = cn;
                    cmd.ExecuteNonQuery();

                    if (goback == "shares")
                    {
                        Shares window = new Shares();
                        window.Show();
                        this.Hide();
                    }
                    else
                    {
                        Clients window = new Clients();
                        window.Show();
                        this.Hide();
                    }
                } catch (SqlException) { MessageBox.Show("Error deleting client."); }
            }
        }
コード例 #3
0
        private void Users_Click(object sender, RoutedEventArgs e)
        {
            Clients user = new Clients();

            user.Show();
            this.Close();
        }
コード例 #4
0
 private void button_Click(object sender, RoutedEventArgs e)
 {
     if (mode == "loan")
     {
         Loans window = new Loans();
         window.Show();
         this.Hide();
     }
     else
     {
         Clients window = new Clients();
         window.Show();
         this.Hide();
     }
 }
コード例 #5
0
 private void button_Click(object sender, RoutedEventArgs e) //return
 {
     if (goback == "shares")
     {
         Shares window = new Shares();
         window.Show();
         this.Hide();
     }
     else
     {
         Clients window = new Clients();
         window.Show();
         this.Hide();
     }
 }
コード例 #6
0
        private void button1_Click(object sender, RoutedEventArgs e) //save
        {
            if (!refresh())
            {
                return;
            }

            string postal = t3.Text;
            string addr   = t5.Text;

            if (!Regex.IsMatch(postal, "^[^()\\*;+='\\\\/]*$") || !Regex.IsMatch(addr, "^[^()\\*;+='\\\\/]*$") || postal.Contains("--") || addr.Contains("--"))
            {
                MessageBox.Show("Invalid characters detected.");
                return;
            }

            try
            {
                SqlCommand cmd = new SqlCommand("UPDATE CLIENTS SET postal='" + postal + "', addr='" + addr + "' WHERE id=" + editing.ID.ToString());
                cmd.Connection = cn;
                cmd.ExecuteNonQuery();

                if (goback == "shares")
                {
                    Shares window = new Shares();
                    window.Show();
                    this.Hide();
                }
                else
                {
                    Clients window = new Clients();
                    window.Show();
                    this.Hide();
                }
            } catch (SqlException) { MessageBox.Show("Error updating database: some fields may contain too much text."); }
        }
コード例 #7
0
        private void button_Click_1(object sender, RoutedEventArgs e)
        {
            if (!refresh())
            {
                return;
            }

            if (!Regex.IsMatch(textBox.Text, "^[^()\\*;+='\\\\/]*$") || !Regex.IsMatch(textBox2.Text, "^[^()\\*;+='\\\\/]*$") || !Regex.IsMatch(textBox3.Text, "^[^()\\*;+='\\\\/]*$") || textBox.Text.Contains("--") || textBox2.Text.Contains("--") || textBox3.Text.Contains("--"))
            {
                MessageBox.Show("Invalid characters detected.");
                return;
            }

            //make sure unique IDs are used when creating things

            SqlCommand cmd = new SqlCommand("SELECT max(id) FROM CLIENTS");

            cmd.Connection = cn;
            int newID = (int)cmd.ExecuteScalar() + 1;

            string gender;

            if (radioButton.IsChecked == true)
            {
                gender = "Male";
            }
            else if (radioButton2.IsChecked == true)
            {
                gender = "Female";
            }
            else
            {
                gender = "Other";
            }

            try
            {
                int  aux  = -1;
                long aux2 = -1;
                if (!int.TryParse(textBoxnif.Text, out aux))
                {
                    MessageBox.Show("Invalid NIF.");
                    return;
                }
                if (!long.TryParse(textBox4.Text, out aux2))
                {
                    MessageBox.Show("Invalid Citizen ID.");
                    return;
                }

                try
                {
                    cmd            = new SqlCommand("INSERT INTO CLIENTS (id, name, addr, postal, citid, gender, nif) VALUES (" + newID + ", '" + textBox.Text + "', '" + textBox2.Text + "', '" + textBox3.Text + "', '" + textBox4.Text + "', '" + gender + "', " + aux + ")");
                    cmd.Connection = cn;
                    cmd.ExecuteNonQuery();

                    Clients window = new Clients();
                    window.Show();
                    this.Hide();
                }
                catch (SqlException) { MessageBox.Show("Error updating database: the NIF might be too big, or some fields may contain too much text."); }
            }
            catch (OverflowException) { MessageBox.Show("The number is too big."); }
        }