Example #1
0
        public Boolean UpdateBlock(BlockBuilding block)
        {
            Boolean isUpdated = false;
            string  query     = "update tblblock set name='" + block.getBlockName() + "', " +
                                "gender='" + block.getGender() + "'," +
                                "description='" + block.getDescription() + "'," +
                                "status='" + block.getStatus() + "'where blockId='" + block.getBlockId() + "';";

            try
            {
                databaseConnection.Open();
                commandDatabase = new MySqlCommand(query, databaseConnection);
                int updatedRow = commandDatabase.ExecuteNonQuery();
                if (updatedRow > 0)
                {
                    isUpdated = true;
                }
                databaseConnection.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Query Error : " + ex.Message);
            }
            return(isUpdated);
        }
Example #2
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            string search = txtSearch.Text;

            BlockController blockController = new BlockController();
            BlockBuilding   block           = blockController.SearchBlock(search);

            txtBlockId.Text     = block.getBlockId();
            txtBlockName.Text   = block.getBlockName();
            txtGender.Text      = block.getGender();
            txtDescription.Text = block.getDescription();
            txtStatus.Text      = block.getStatus();
        }
Example #3
0
        public Boolean AddBlock(BlockBuilding block)
        {
            Boolean userAdded = false;
            string  query     = "insert into tblblock (name, gender, description,status)" +
                                "values ('" + block.getBlockName() + "', '" + block.getGender() + "', '" + block.getDescription() + "', '" + block.getStatus() + "')";

            try
            {
                databaseConnection.Open();
                commandDatabase = new MySqlCommand(query, databaseConnection);
                int affectedRows = commandDatabase.ExecuteNonQuery();
                if (affectedRows > 0)
                {
                    userAdded = true;
                }
                databaseConnection.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Query Error : " + ex.Message);
            }
            return(userAdded);
        }