Esempio n. 1
0
        private void verifyReceiptToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Misc.GetReceiptString receiptString = new Misc.GetReceiptString();
            receiptString.ShowDialog();
            if (receiptString.confirmed)
            {
                string          receiptCode = receiptString.receiptCode;
                MySqlConnection connection  = Database.GetConnection();
                connection.Open();

                string       sql     = "SELECT * FROM tbl_jobs WHERE receiptKey = @receiptCode";
                MySqlCommand command = new MySqlCommand(sql, connection);

                command.Parameters.AddWithValue("@receiptcode", receiptCode);

                MySqlDataReader reader = command.ExecuteReader();

                if (reader.Read())
                {
                    DialogResult result = MessageBox.Show("Job Found, would you like to open?", "Success", MessageBoxButtons.YesNo);
                    if (result == DialogResult.Yes)
                    {
                        Jobs.View viewJob = new Jobs.View(reader.GetInt32("jobID"));
                        viewJob.ShowDialog();
                    }
                }
                else
                {
                    MessageBox.Show("Invalid receipt code, please try again");
                }
            }
        }
Esempio n. 2
0
        private void buttonVerify_Click(object sender, EventArgs e)
        {
            Misc.GetReceiptString getReceiptString = new Misc.GetReceiptString();
            getReceiptString.ShowDialog();

            if (getReceiptString.confirmed)
            {
                MySqlConnection connection = Database.GetConnection();
                connection.Open();

                string       sql     = "SELECT jobID FROM tbl_jobs WHERE receiptKey = @receiptKey";
                MySqlCommand command = new MySqlCommand(sql, connection);
                command.Parameters.AddWithValue("@receiptKey", getReceiptString.receiptCode);

                MySqlDataReader data = command.ExecuteReader();
                if (data.Read())
                {
                    if (data.GetInt32(data.GetOrdinal("jobID")) == jobID)
                    {
                        MessageBox.Show("Receipt is valid");
                    }
                    else
                    {
                        MessageBox.Show("Receipt is invalid");
                    }
                }
                else
                {
                    MessageBox.Show("Receipt is invalid");
                }
            }
        }