Exemple #1
0
        private void SaveDataToDatabase()
        {
            string fullName = TextBoxName.Text;

            try
            {
                Class.forName("com.mysql.jdbc.Driver");
                Connection c = (Connection)DriverManager.getConnection(Resource.DATABASE_URL, Resource.USERNAME, Resource.PASSWORD);

                PreparedStatement ps = c.prepareStatement("update info set Name = ? ,  Address = ? , phone_number = ? , Email = ? , ImagePath = ? , BirthDate = ? where account_number = ? ");
                ps.setString(1, fullName);
                ps.setString(2, textBox_address.Text);
                ps.setString(3, textBox_phonenumber.Text);
                ps.setString(4, textBox_email.Text);
                ps.setString(5, _imageFilePath);
                ps.setString(6, myDatePicker.Text);
                ps.setString(7, Accc);
                ps.executeUpdate();
                c.close();
                //MaterialDesignDialogBox.Show("Sucess", "Changes done sucessfully", "OK");
            }
            catch (SQLException exception)
            {
                //MaterialDesignDialogBox.Show("Error", "Something went wrong." + exception.Message, "OK");
            }
        }
Exemple #2
0
        private void SaveNewName(string name)
        {
            try
            {
                Class.forName("com.mysql.jdbc.Driver");
                Connection c = (Connection)DriverManager.getConnection(Resource.DATABASE_URL, Resource.USERNAME, Resource.PASSWORD);

                java.sql.PreparedStatement ps = c.prepareStatement("update info set Name = ? where account_number = ?");
                ps.setString(1, name);
                ps.setString(2, accNum);
                ps.executeUpdate();
                c.close();
                MessageBox.Show("Changes saved sucessfully");
                new LoggedIn().Show();
            }
            catch (SQLException exception)
            {
                MessageBox.Show(exception.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Stop);
            }
        }