Example #1
0
        private void button6_Click(object sender, RoutedEventArgs e)
        {
            Shares window = new Shares();

            window.Show();
            this.Hide();
        }
        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."); }
            }
        }
 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();
     }
 }
        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."); }
        }