private void btnCreateAccount_Click(object sender, EventArgs e)
        {
            string username = tbxUsername.Text;
            string password = tbxPassword.Text;

            string queryUsername = $"select username from account " +
                                   $"where username = '******';";

            DataTable Usernamedtbl = Filler.DataTableFiller(queryUsername);

            if (Usernamedtbl.Rows.Count != 0)
            {
                MessageBox.Show("Username Already Exists", "Error", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
            else
            {
                if (lblPasswordQuality.ForeColor != Color.Green)
                {
                    MessageBox.Show("Create Stronger Password", "Error", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
                else if (tbxPassword.Text != tbxConfirmPassword.Text)
                {
                    MessageBox.Show("Passwords Do Not Match", "Error", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
                else
                {
                    Account g = new Account(username, password);

                    string queryCreateAccount = $"insert into account values('{g.GetUsername()}','{Encryption.sha256(g.GetPassword())}');";

                    Filler.InserterDeleter(queryCreateAccount);

                    MessageBox.Show("Account Created", "New", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);

                    LogIn li = new LogIn();

                    this.Hide();
                    li.ShowDialog();
                    li.Dispose();
                    this.Close();
                }
            }
        }
Пример #2
0
        private void fillCustomerDataTable()
        {
            string query = "select firstname, lastname, telephone, email " +
                           "from customer;";

            DataTable Customerdtbl = Filler.DataTableFiller(query);

            foreach (DataRow row in Customerdtbl.Rows)
            {
                string[] rowarray = { row["firstname"].ToString().Trim(),
                                      row["lastname"].ToString().Trim(),
                                      row["telephone"].ToString().Trim(),
                                      row["email"].ToString().Trim() };

                customerGrid.Rows.Add(rowarray);
            }
        }
Пример #3
0
        private void btnDeleteInv_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Are You Sure You Wish To Delete", "Warning", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                string vin = inventoryGrid.CurrentRow.Cells[0].Value.ToString();

                string query = $"delete from inventory where vin = '{vin}';";
                Filler.InserterDeleter(query);

                inventoryGrid.Rows.Clear();
                fillInventoryDataTable();
            }
            else if (dialogResult == DialogResult.No)
            {
            }
        }
Пример #4
0
        private void fillSalesDataTable()
        {
            string query = "select firstname, lastname, modelyear, make, model, modeltrim, price " +
                           "from customer, inventory, sales " +
                           "where sales.customerID = customer.customerID " +
                           "and sales.inventoryID = inventory.inventoryID;";

            DataTable Salesdtbl = Filler.DataTableFiller(query);

            foreach (DataRow row in Salesdtbl.Rows)
            {
                string[] rowarray = { row["firstname"].ToString().Trim() + " " + row["lastname"].ToString().Trim(),
                                      row["modelyear"].ToString().Trim() + " " + row["make"].ToString().Trim() + " " + row["model"].ToString().Trim() + " " + row["modeltrim"].ToString().Trim(),
                                      row["price"].ToString().Trim() };

                salesGrid.Rows.Add(rowarray);
            }
        }
Пример #5
0
        private void btnDeleteCus_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Are You Sure You Wish To Delete", "Warning", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                string no = customerGrid.CurrentRow.Cells[2].Value.ToString();

                string query = $"delete from customer where telephone = {no};";
                Filler.InserterDeleter(query);

                customerGrid.Rows.Clear();
                fillCustomerDataTable();
            }
            else if (dialogResult == DialogResult.No)
            {
            }
        }
Пример #6
0
        private void fillInventoryDataTable()
        {
            string query = "select vin, color, make, model, modeltrim, modelyear, mileage " +
                           "from inventory " +
                           "where sold = 0;";

            DataTable Inventorydtbl = Filler.DataTableFiller(query);

            foreach (DataRow row in Inventorydtbl.Rows)
            {
                string[] rowarray = { row["vin"].ToString().Trim(),
                                      row["color"].ToString().Trim(),
                                      row["modelyear"].ToString().Trim(),
                                      row["make"].ToString().Trim(),
                                      row["model"].ToString().Trim(),
                                      row["modeltrim"].ToString().Trim(),
                                      row["mileage"].ToString().Trim() };

                inventoryGrid.Rows.Add(rowarray);
            }
        }
Пример #7
0
        private void btnLogIn_Click(object sender, EventArgs e)
        {
            string username = tbxUsername.Text;
            string password = tbxPassword.Text;

            string queryUsername = $"select username, password from account " +
                                   $"where username = '******';";

            DataTable Usernamedtbl = Filler.DataTableFiller(queryUsername);

            if (Usernamedtbl.Rows.Count == 0)
            {
                MessageBox.Show("User Not Found", "Error", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
            else
            {
                foreach (DataRow row in Usernamedtbl.Rows)
                {
                    if (row["password"].ToString().Trim() != Encryption.sha256(password))
                    {
                        MessageBox.Show("Incorrect Password", "Error", MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                    }
                    else
                    {
                        DataViewControl dvc = new DataViewControl();

                        this.Hide();
                        dvc.ShowDialog();
                        dvc.Dispose();
                        this.Close();
                    }
                }
            }
        }
Пример #8
0
        private void btnAddCar_Click(object sender, EventArgs e)
        {
            if (tbxVin.Text.Length == 17)
            {
                if (String.IsNullOrEmpty(tbxMake.Text) == false)
                {
                    if (String.IsNullOrEmpty(tbxModel.Text) == false)
                    {
                        if (String.IsNullOrEmpty(tbxTrim.Text) == false)
                        {
                            if (String.IsNullOrEmpty(tbxColor.Text) == false)
                            {
                                try
                                {
                                    vin     = tbxVin.Text;
                                    year    = int.Parse(cbxYear.Text);
                                    make    = tbxMake.Text;
                                    model   = tbxModel.Text;
                                    trim    = tbxTrim.Text;
                                    color   = tbxColor.Text;
                                    mileage = int.Parse(tbxMileage.Text);

                                    string query = $"insert into inventory values('{vin}','{color}','{make}','{model}','{trim}',{year},{mileage},0);";
                                    Filler.InserterDeleter(query);

                                    DataViewControl dvc = new DataViewControl();
                                    this.Hide();
                                    dvc.tabControl1.SelectedTab = dvc.inventoryPage;
                                    dvc.ShowDialog();
                                    this.Close();
                                }
                                catch (Exception ex)
                                {
                                    MessageBox.Show(ex.Message);
                                }
                            }
                            else
                            {
                                MessageBox.Show("Please Enter Color");
                            }
                        }
                        else
                        {
                            MessageBox.Show("Please Enter Trim");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Please Enter Model");
                    }
                }
                else
                {
                    MessageBox.Show("Please Enter Make");
                }
            }
            else
            {
                MessageBox.Show("Please Enter Valid Vin");
            }
        }