public void CheckifIDinTable()
        {
            FunctionsForAllProgram funcs = new FunctionsForAllProgram();

            // existing user
            bool IDExists = funcs.ifIDinTable(3233, "Users");

            Assert.IsTrue(IDExists);

            // not existing user
            IDExists = funcs.ifIDinTable(99999, "Users");
            Assert.IsFalse(IDExists);
        }
예제 #2
0
        private void deleteMessageButton_Click(object sender, EventArgs e)
        {
            DBconnect db = new DBconnect();
            int       id;

            try
            {
                id = Convert.ToInt32(this.globalMessageId_box.Text);
            }
            catch
            {
                MessageBox.Show("Empty ID field or non-digit symbol been inputed.");
                return;
            }
            String query = "DELETE FROM GlobalMEssages WHERE ID=" + id;

            FunctionsForAllProgram func = new FunctionsForAllProgram();
            bool existCheck             = func.ifIDinTable(id, "GlobalMessages");

            if (existCheck)
            {
                try
                {
                    bool result = db.executionQuery(query);
                    if (result)
                    {
                        MessageBox.Show("Global message with id : " + id + " removed from database");
                    }
                }
                catch
                {
                    MessageBox.Show("Cannot delete message with id : " + id);
                }
            }
            else
            {
                MessageBox.Show("Message with this id does not exists");
            }
        }