How to code a rewards app

mlkshake 1 Reputation point
2022-10-08T08:17:12.447+00:00

I’m trying to code a rewards app that works with Microsoft access database that can
• adds a customer - FName, LName, UserName, EmailAddress, PromoMaterialEmail, AccType(business or personal), Business type( eg Interior decorator )
• if they purchase over 120, they get a stamp (point)
• when they collect 12 stamps, they receive a in store voucher that is generated for them
• the system should also be able to send promotional material via email of customers who check that option

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,407 questions
{count} votes

4 answers

Sort by: Most helpful
  1. mlkshake 1 Reputation point
    2022-10-10T07:44:36.793+00:00

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    using System.Data.OleDb;

    namespace OhFlowerz
    {
    public partial class AddCust : Form
    {
    //creates a new connection to your DB
    OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=""C:\Users\Shaikh\Documents\OhFlowers - Copy.accdb""");
    public AddCust()
    {
    InitializeComponent();
    }

        private void btnAddCust_Click(object sender, EventArgs e)  
        {  
            //open the connection to your DB  
            try  
            {  
    
                conn.Open();  
                //SQL Command  
                OleDbCommand cmd = conn.CreateCommand();  
                cmd.CommandType = CommandType.Text;  
                cmd.CommandText = "incert into OhFlowers - Copy(FirstName,LastName,UserName,Email,PromotionalMaterial,BusinessType)values('" + textBox1.Text + "', '" + textBox4.Text + "', '" + textBox3.Text + "','" + textBox2.Text + "', '" + textBox3.Text + "','" + txtPromo.Text + "', '" + txtBusType.Text + "')";  
                cmd.ExecuteNonQuery();  
                MessageBox.Show("New Customer Added", "Access Connect", MessageBoxButtons.OK, MessageBoxIcon.Information);  
                conn.Close();  
                new Home().Show();  
                this.Close();  
    
            }  
            //Failed to connect to tour DB  
            catch (Exception ex)  
            {  
    
                MessageBox.Show(ex.Message, "Access Connect", MessageBoxButtons.OK, MessageBoxIcon.Information);  
    
            }  
        }  
    }  
    

    }

    0 comments No comments

  2. mlkshake 1 Reputation point
    2022-10-10T07:45:16.793+00:00

    • For the web based application, I have no idea how to go about doing it. if you can suggest anything I can watch or do.

    0 comments No comments

  3. mlkshake 1 Reputation point
    2022-10-10T07:46:08.397+00:00

    it was not allowing me to send it all at once hence the many messages.

    0 comments No comments

  4. Jack J Jun 24,311 Reputation points Microsoft Vendor
    2022-10-11T08:04:05.923+00:00

    @mlkshake , Welcome to Microsoft Q&A, based on my test, I reproduced your problem.

    I have some suggestions for your error.

    First, Please use the command correctly insert instead of incert.

    Second, We need to make sure that the number of parameters in the front should be consistent with the number of parameters in the back.

    I noted that you have 6 parameters in the front, but you have 7 textbox to give their value.

    Third, I recommend that you use SqlParameter to set the insert text if your parameter's count is over 3.

    Here is a code example you could refer to.

    code.txt

    Hope my advice could help you.

    Best Regards,
    Jack

    0 comments No comments